hi all
i have a problem with this code .what is wrong with it :


invoke RegCreateKeyEx,HKEY_CURRENT_USER,addr soft0,
      NULL,NULL,REG_OPTION_NON_VOLATILE,
      KEY_ALL_ACCESS,NULL,addr reghand,addr disp 


invoke RegQueryValueEx,reghand,addr regname,NULL,0,0,yek

where :

disp db "REG_OPENED_EXISTING_KEY",0

soft0 db "Software\Yahoo\Pager",0
regname db "Yahoo! User ID",0
reghand dd ?

I know that RegCreateKeyEx return a true handle in reghand but but i dont know why RegQueryValueEx doesnt work!!!
thx


Posted on 2005-08-06 01:52:24 by soorena
You must use "addr reghand" - RegCreateKeyEx wants a pointer to the variable that will receive the key, not the value of the key variable :)
Posted on 2005-08-06 03:42:25 by f0dder
thx for your answer f0dder but i found the problem in RegOpenKeyEx and this is work :


invoke RegCreateKeyEx,HKEY_CURRENT_USER,addr soft0,
      NULL,NULL,REG_OPTION_NON_VOLATILE,
      KEY_ALL_ACCESS,NULL,addr reghand,addr disp 

invoke RegQueryValueEx,reghand,addr regname,0,0,addr titlebuf,addr yek

where :
titlebuf db 100 dup(?)
yek DWORD 100
reghand dd ?
soft0 db "Software\Yahoo\pager\",0
regname db "Yahoo! User ID",0
disp db "REG_OPENED_EXISTING_KEY",0


now this is work
thx all
Posted on 2005-08-06 04:17:35 by soorena
Sorry, I responded a bit too soon after waking up :blush:, I dunno why I read your CreateKey as passing by value instead of by address.

Unless you'll be writing the key, you might want to use RegOpenKeyEx instead of RegCreateKeyEx, so you won't pollute the user's registry if he doesn't have the Yahoo stuff installed. And if you're only going to read, you should use KEY_READ access (shouldn't matter much when dealing with HKCU, but for HKLM on NT machines with non-administrator accounts, it certainly does).
Posted on 2005-08-06 05:15:45 by f0dder
tanck you f0dder i got it
Posted on 2005-08-06 15:33:19 by soorena