im trying to query my registry at a certain location. the registry currently has this entry:


"Sound"="C:\\test.wave"

I must be overlooking something because i dont get an error_success which means it worked


.data

ValueLocation2 db "Software\Terminator",0
NewValue5 db "Sound",0
RegType db "REG_SZ",0

.data?
hOpenKey HANDLE ?
RegCheckBuffer1 dd ?
RegCheckBuffer0 db 256 dup(?)

.code
invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,ADDR ValueLocation2,0,KEY_ALL_ACCESS,addr hOpenKey
mov RegCheckBuffer1,255
invoke RegQueryValueEx,hOpenKey, addr NewValue5,0,addr RegType,addr RegCheckBuffer0,addr RegCheckBuffer1
.if eax == ERROR_SUCCESS
invoke MessageBox,0,addr RegCheckBuffer0,0,0
.endif


EDIT: after further testing ive come to the conclusion that my string im querying isnt null terminated. i first put the string into the registry from an edit box. i called getwindowtext and stored it into a buffer then set the registry setting using the contents of the buffer.

the reason i came to this conclusion is because i set a new registry entry with a null terminated string i made and the registry query worked fine then.

test db "test.wave",0 ;<=== this is the new string i entered

now how would i go about null terminating my string before i querry it?
Posted on 2002-01-18 14:20:02 by smurf
well ok now since even more further testing i know for a fact it has to do with the string stored in my registry not being null terminated.

so if i get my initial string from an editbox how would i null terminate it before i set it into the registry so later on when i want to query it i wont have a problem?
Posted on 2002-01-18 17:58:45 by smurf
well whatever i did its working now. damn took me all day to figure this out and i still really dont know what the heck i was doing wrong.
Posted on 2002-01-18 22:45:47 by smurf
You will probably find that your RegOpenKeyEx call will still fail on NT platforms because you have requested KEY_ALL_ACCESS, try changing this to KEY_READ OR KEY_WRITE.

To null terminate the string you get from the edit box, fill your buffer with NULLS before sending the WM_GETTEXT, as long as your buffer is longer than the string (which it should always be :)), then you do not need to worry about NULL terminating it.
Posted on 2002-01-19 04:51:43 by sluggy
thanks sluggy the wm_gettext message will come in very handy. i wish i had known about the usefullness of that message sooner. your right about me having problems with the nt platform especially if the user doesnt have adminstration priviledges. i will change that in the program im writing.
Posted on 2002-01-19 14:42:23 by smurf
your right about me having problems with the nt platform especially if the user doesnt have adminstration priviledges
My dev machine here at home is a dual boot Win2K Prof/Win98. My main login on the 2K OS (why would i ever boot into 9x???) is set up as a power user, and KEY_ALL_ACCESS still fails on that. So last time i did registry stuff, i logged in as admin, the call still failed. I even wrote the equivalent section of code in VB just to check my results.

So, why do they have KEY_ALL_ACCESS when it fails even with admin privileges? I dunno, but there will be some logic to it (no matter how warped), and there has to be some really obtuse method of using it.
Posted on 2002-01-20 02:54:18 by sluggy
smurf, you should use HKEY_CURRENT_USER, unless the administrator (!)
specifies "install for all users" while installing the application.
You have more privileges over HKCU than HKLM :).
Posted on 2002-01-20 05:38:32 by f0dder