Page 1 of 1

pure basic dll problem

Posted: Wed Feb 22, 2012 3:08 pm
by sidegame
Hi there!
i made a DLL using pure basic which Write String value in registry it has 4 arguments
argument0[HKey],argument1[Subkey],argument2[String], argument3[Value]
but the problem is when i run the game nothing happening i checked registry editor no value was written in registry. :(

here is my the Pure basic source

;-========= Write String to Registry ============
ProcedureDLL RegWriteString(HKMain,HKSub$,HKEntry$,HKValue.
s)
If RegCreateKeyEx_(HKMain, HKSub$, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo)= #ERROR_SUCCESS
RegSetValueEx_(NewKey, HKEntry$, 0, #REG_SZ, @HKValue,256)
RegCloseKey_(NewKey)
EndIf
EndProcedure



and this is DLL define in game maker


global.myfunction=external_define("test.dll"
,"RegWriteString", dll_stdcall, ty_string, 4, ty_string ,ty_string,ty_string,ty_string)
external_call(global.myfunction,argument0,argument1,
argument2,argument3)



and in create event


//Creat event
scr_dll("#HKEY_CURRENT_USER","Software\
app1\Data1","Data0000","test"
)



i don't know what i did wrong with the code, :cry: please help me can some one make it correct i am really serous.
actually i posted this topic in game maker community but some one answered me that registry is not allowed in forum so they locked my topic. so i post it here may be some one can help me

Re: pure basic dll problem

Posted: Wed Feb 22, 2012 3:17 pm
by Derren
Try calling the DLL from purebasic.
If it works, just write a DLL that creates a text file with the score, for example and ask again inthe game maker community.

Re: pure basic dll problem

Posted: Wed Feb 22, 2012 4:32 pm
by Kuron
sidegame wrote:but the problem is when i run the game nothing happening i checked registry editor no value was written in registry. :(
I haven't looked at your code, but you are likely looking in the wrong part of the registry.

You have not specified what OS you are using.

Game Maker is a 32-bit program and would only be able to use a 32-bit DLL. Most versions of Windows 7 shipped on PCs is a 64-bit version. The 64-bit versions of Windows can't run 32-bit software. 32-bit software has to run under emulation using WoW64. If a 32-bit program tries to write to the registry, it will write to the 32-bit equivalents reserved for the emulator.

You are likely looking in the normal part of the registry that can only be accessed by 64-bit software. You need to look in the 32-bit equivalents to see if the registry entry is actually being written.

Re: pure basic dll problem

Posted: Wed Feb 22, 2012 7:59 pm
by Danilo
Kuron wrote:The 64-bit versions of Windows can't run 32-bit software.
32-bit software has to run under emulation using WoW64.
Although it is called emulation layer, 32bit applications are not emulated on AMD64/Intel64 processors.
It is only emulated on Intel Itanium processors (IA-64 architecture) because it has a different instruction set.

The emulation layer handles switching to 32bit mode and redirects some DLL calls etc.,
but the code itself runs native on AMD64/Intel64 processors. It makes a difference
for the execution speed.

Performance and Memory Consumption Under WOW64:
Processor hardware. Instruction emulation is performed on the chip.
On the x64 processor, instructions are executed natively by the micro-architecture. Therefore, execution speed under WOW64 on x64 is similar to its speed under 32-bit Windows.
On the Intel Itanium processor, more software is involved in the emulation, and performance suffers as a result.
http://en.wikipedia.org/wiki/WOW64#Architectures

It is a good idea to relativize conclusions like "The 64-bit versions of Windows can't run 32-bit software."

Re: pure basic dll problem

Posted: Thu Feb 23, 2012 12:21 am
by Kuron
AMD vs Intel has no bearing on my comments. If you are trying to run 32-bit software on a 64-bit version of Windows, your software will be run under WoW64. This is the ONLY way 32-bit software can be run under a 64-bit version of Windows. Your software will need to adhere to the 32-bit equivalents in the registry which are used by the emulator, as well as the 32-bit equivalents of program files and the system directory which are used by the emulator. These restrictions are put in place for a reason and apply no matter what type of processor you are using. Running your 32-bit software on a 64-bit version of Windows 7 installed on an AMD system does not magically change this and does not do away with the requirements and restrictions of the emulator.

Window 7 64's redirection should handle all of this automatically (in theory). However, if you are going to manually look into the registry to verify if your 32-bit app has written something properly, you need to look in the 32-bit equivalent of the node in question. :wink:

Re: pure basic dll problem

Posted: Thu Feb 23, 2012 6:05 am
by sidegame
thanks from all of you for replying to my topic but i want to know is there any other way to make dll for game maker using pure basic that could enter value in registry :?

Re: pure basic dll problem

Posted: Thu Feb 23, 2012 6:14 am
by ts-soft
What is HKMain?
You can write to #HKEY_CURRENT_USER without admin privilege, the other sections only readable with #KEY_READ!

Re: pure basic dll problem

Posted: Thu Feb 23, 2012 6:26 am
by sidegame
ts-soft wrote:What is HKMain?
You can write to #HKEY_CURRENT_USER without admin privilege, the other sections only readable with #KEY_READ!
ts-soft dude!
i tried that but it show an error RegWriteString() is not a function, array, macro or linked list.