Hey gurus.

Stuck again. This time, I am pretty sure that this procedure is working correctly but that I am somehow not reading the result right.



invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE, addr RSectn, 0, KEY_READ, addr Result
mov regResult, eax

invoke RegQueryValueEx, HKEY_LOCAL_MACHINE, addr RValue, NULL, NULL, NULL, NULL
mov ValueExists, eax

.if ValueExists == ERROR_SUCCESS
invoke SetWindowText, hButton, addr DisableOC ;If it is there...
.else
invoke SetWindowText, hButton, addr EnableOC ;If it isn't there...
.endif

invoke RegCloseKey, HKEY_LOCAL_MACHINE
xor eax, eax
ret


The object here is to check if a value is present in a subkey and if it isn't, change the text of my button to "Disable" from "Enable." Alternately, if the key value does exist, the button caption is changed to "Enable."

Where I am going wrong here, I don't know. So.. I am here to ask you all to help me through my slump in figuring things out on my own.

Thanks a lot in advance, all. Be safe.

The Beginner
Posted on 2003-06-03 16:19:06 by The Beginner
The line:
invoke RegQueryValueEx, HKEY_LOCAL_MACHINE, addr RValue, NULL, NULL, NULL, NULL
attempts to read HKLM\RValue, which is probably not what you want. Try this:

[size=12]invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE, addr RSectn, 0, KEY_READ, addr Result

.if EAX == ERROR_SUCCESS
invoke RegQueryValueEx, Result, addr RValue, NULL, NULL, NULL, NULL
.if EAX == ERROR_SUCCESS
invoke SetWindowText, hButton, addr DisableOC;If it is there...
.else
invoke SetWindowText, hButton, addr EnableOC;If it isn't there...
.endif
invoke RegCloseKey, Result
.endif
ret[/size]
Posted on 2003-06-03 17:00:47 by iblis
Wow, heh, that was a simple error that I never saw coming. Thanks a lot, iblis! I appreciate the help on this. It was driving me insane but now it is working perfectly.
Posted on 2003-06-04 14:05:12 by The Beginner