Hello,

when i try to enum the registry with the function ,i found successfull the first keys from the registry.

i try to use the same function then again by using the keyname i found.
like i found : "test" and inside "test2" i open new key to enum like "test\test2"

but i only get all keys inside one key ,not all keys inside the whole reg.

if i copy the function and call it with keyname i found ,i get first key inside a key.
but this means i must copy this 10 times to browse 10 keys deep inside a key.

im shure i didnt see the right way and miss something.

how can i enum all keys + subkeys from the registry ?

Thanks




ENUM_REG Proc
call RegOpenKeyA, TopKey,offset BUFF_KeyLoc,offset pKey ;open first key when BUFF_KeyLoc is emtpy
cmp eax,ERROR_SUCCESS ; if no key ,exit
jnz error_out
.WHILE TRUE
call RegEnumKeyA,pKey , IndexNum,offset BUFF_KeyName, 256 ;enum keynames from 0 up t ?(IndexNum)
.BREAK .IF ( eax != ERROR_SUCCESS )
call lstrlen,offset BUFF_KeyName ;if keyname found
.if eax>0

call MessageBox,0,offset BUFF_KeyName,offset BUFF_KeyName,0 ; pop up messagebox

.endif
inc IndexNum ;inc keynumber
.ENDW

error_out:
call RegCloseKey,offset pKey ;close key
mov IndexNum,0
ret
ENUM_REG Endp
Posted on 2003-03-20 06:55:42 by xanthos
First, you should really use the Reg...Ex api functions since the normal ones call the Ex functions (I think) also, the Ex functions let you specify what type of access you need for the keys/values (this is needed on NT) and the non Ex functions are for 16 bit apps (os's)

Try the below: Whipped it up quick... not tested...


ENUM_REG Proc uses ebx esi
LOCAL ft:FILETIME
LOCAL lpcName:DWORD
LOCAL BUFF_KeyName[256]:BYTE

push offset pKey ;
push KEY_ENUMERATE_SUB_KEYS ;
push 0 ;
push offset BUFF_KeyLoc ;
push HKEY_CURRENT_USER ;
call RegOpenKeyExA ; Open key for enumeration
test eax, eax ; if no key ,exit
jnz error_out

xor ebx, ebx
GetNextKey:
lea eax, ft ;
push eax ;
push 0 ;
push 0 ;
push 0 ;
mov lpcName, 256 ; Has to be the size of our name buffer
lea ecx, lpcName ;
push ecx ;
lea esi, BUFF_KeyName ;
push esi ;
push ebx ; Our counter
push hSourceKey ;
call RegEnumKeyExA ; Get next key
cmp eax, ERROR_NO_MORE_ITEMS; Anymore keys?
je Done ; no, leave

push esi ; address of name buffer
call lstrlen

push 0
push esi
push esi
push 0
call MessageBox

inc ebx
jmp GetNextKey
Done:
push pKey
call RegCloseKey

error_out:
ret

ENUM_REG Endp
Posted on 2003-03-20 16:33:03 by Gunner
THANKS ALOT !

now i understand why sometime in a source stand Reg..Ex or RegExA or Reg only

i think i should by some books first !
Posted on 2003-03-21 04:38:24 by xanthos