hossa,

i start coding my own registry enum function and on my win98 se it work fine ,then i send it to a friend who use NT and it wont work.
he is loged in as admin ,i dont use KEY_ALL_ACCESS.

any ideas what might be wrong ?

thanks


.386
.MODEL FLAT,STDCALL


UNICODE=0

include w32.inc



extrn lstrcat : proc
extrn lstrcpy :Proc
extrn lstrcatA :Proc
extrn lstrcmpi :Proc
extrn RegOpenKeyA:proc
extrn RegEnumValueA:proc
extrn RegEnumKeyEx:proc

.DATA
;[--------==========================================================--------];

IndexNum dd 0
szRegPath db 256 dup(?),0
szKeyName db "\" ,0
Error db "ERROR",0

TType dd ?
pKey dd ?
lpszBuffer dd ?

.data?
szTopKey dd ?

.CODE
;[--------==========================================================--------];

main:

mov szTopKey, HKEY_LOCAL_MACHINE
call EnumReg

call ExitProcess ,0

;[--------==========================================================--------];
EnumReg proc

firstrun:
mov TType, REG_NONE
call RegCreateKey,szTopKey,offset szKeyName,offset pKey
cmp eax,ERROR_SUCCESS
jnz @Error

@loop:
call RegEnumKey, pKey, IndexNum, offset szRegPath, 255
cmp eax,ERROR_NO_MORE_ITEMS
je @endloop
call RegQueryValueEx, pKey, lpszValueName,NULL, offset TType, lpszBuffer, 256
call MessageBox,0,offset szRegPath,offset szRegPath,+MB_YESNO
cmp eax,IDNO
je @endloop
inc IndexNum
jmp @loop

@endloop:
call RegCloseKey, pKey
mov IndexNum, 0
ret

@Error:
call MessageBox,0,offset Error,offset Error,0
ret


EnumReg endp
;[--------==========================================================--------];

ends
end main
Posted on 2002-03-03 06:21:20 by Max
Hi,

i once had the same problem, too. dunno why...but KEY_ALL_ACCESS did it!

NOP
Posted on 2002-03-03 06:57:14 by NOP-erator
--------
but KEY_ALL_ACCESS did it!
--------

this mean it worked for you ?
because i try it with :

call RegCreateKey, szTopKey,offset szKeyName,0,0,0,KEY_ALL_ACCESS,0,offset pKey,offset TType

and again..error

if i use regcreatekey as single function it worked and i set a new key but if i use it in the enum function not.
thats hard to understand.

how do you set your key on nt ?
Posted on 2002-03-03 09:00:13 by Max
Max,

may be that is because your function call "RegEnumValueEx" is still wrong. Last parameter is a pointer to a dword containing the size of the buffer (and will be filled by the function with length of value). I vaguely remember having posted that some time ago.

japheth
Posted on 2002-03-03 09:40:03 by japheth
hossa

so there is the misstake :)
thanks !

since im a newbie i take the calls to work with the registry from VomBonjour (sorry if name is wrong) registry samples.
possible he had to check his sources ,too :)
i browse now google to see how to set regkeys right ,seams most use nt here but dont know how to set keys so i make a sample tutorial for working with registry :)

ps: the source works well on Win98se so its hard to understand that the error i get on NT come from a wrong reg call :-)
Posted on 2002-03-04 04:52:49 by Max
Don't use KEY_ALL_ACCESS under NT that's it.
It mentioned in many sources.
And there is no need for KEY_ALL_ACCESS whatever.
Exept of course as excuse for lazyness.
Posted on 2002-03-04 06:30:02 by The Svin
hossa ,

thanks for the answer....but
i first dont use key_all_access ,i use key_write and it wont work...i read about this in the board archiv.

now after browsing google and downloading some samples im wirred !
every source use another way to use the registry :(
one use regopenkey ,other regopenkeyA ,Ex ....
regenum the same...Ex,ExA,A
why are more ways for read/write regkeys ?
when i start with the registry i think there is only one way you can use it.

yesterday i start with the source from VomBonjour ,regenum and port it to tasm.
ok ,now i understand more what i do yesterday and i modify it but again it work on win98 only.
on nt i get the error message ,so the first reg call is wrong.
i also try the function with key_write and again...error

im not lazy !
but coding this on win98 ,testing it and when it work mailing to a friend ... wait that he test it... get answer mail = wont work.
sit again ,think where is the error....fix some small lines ,try again...it work send to my friend ,get back error...become MAD.

if i ask here i browse google or try hours try & error.
i dont like it to ask questions like.....hey fix my code..do it for me.
if i have no client to work for i spend my time learning by doing.
so sometime i ask more because i work more with asm ,sometime im weeks not here because i work for other people.
im not 20 and have all time in my life to learn from books and so - i had to feet me and others ,pay my bills.
only sayed as lame excuse ,for lame questions :-)

new code
-----------------------------------------



mov szTopKey, HKEY_LOCAL_MACHINE
call EnumReg

call ExitProcess ,0

;[--------==========================================================--------];
EnumReg proc

firstrun:
mov TType, REG_SZ
call RegCreateKeyExA,szTopKey,offset szKeyName,0,0,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0,offset pKey,offset TType
cmp eax,ERROR_SUCCESS
jnz @Error

@loop:
call RegEnumKeyA,pKey,IndexNum,offset szRegPath,256
cmp eax,ERROR_NO_MORE_ITEMS
je @endloop
call RegCloseKey, pKey

call MessageBox,0,offset szRegPath,offset szRegPath,+MB_YESNO
cmp eax,IDNO
je @endloop
inc IndexNum
jmp @loop

@endloop:
call RegCloseKey, pKey
mov IndexNum, 0
ret

@Error:
call RegCloseKey, pKey
call MessageBox,0,offset Error,offset Error,0
ret


EnumReg endp


-----------------------

any ideas what now might be wrong ?
Posted on 2002-03-04 08:28:54 by Max
Max,

if u use nt u "must" know that u cant set the regkey "\" to hkey_local_machine
i used it to get the first entry...

then on NT are much restrictions so create a reg key to enum the reg is stupid and better is open reg key.

there is no use of key_all_access ,thats right...in fact there is no use of any key_write or so !

the code should look like this and works well under nt and win9x,win2k

.DATA
;[--------==========================================================--------];
IndexNum dd 0

Error db "Error",0
Found db "Found" ,0

TType dd ?
pKey dd ?

.data?
szTopKey dd ?
szRegPath db 255 dup (?)

.code
;[--------==========================================================--------];

main:

mov szTopKey, HKEY_LOCAL_MACHINE
call EnumReg

call ExitProcess ,0

;[--------==========================================================--------];
EnumReg proc
call RegOpenKeyA, szTopKey,0, offset pKey
.WHILE TRUE
call RegEnumKey, pKey, IndexNum, offset szRegPath, 255
.BREAK .IF ( eax != ERROR_SUCCESS )
call MessageBox,0,offset szRegPath,offset Found,0
inc IndexNum
.ENDW
call RegCloseKey, pKey
ret
EnumReg endp

-----------------

if u dont know it before im happy to submit my first helpfull src. to this board :)
Posted on 2002-03-04 13:35:16 by Max