News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

RegEnumKeyEx

Started by mariø, February 23, 2005, 03:46:50 PM

Previous topic - Next topic

mariø

Hello,
trying to get all the keys and values of a specific registry entry.
this code I have wrote returns ERROR_NO_MORE_ITEMS in the first call to RegEnumKeyEx
and i have items in this key...




sKey db "Software\Microsoft\Windows\CurrentVersion\Run",0


DisplayRegistry proc
LOCAL hKey:DWORD
LOCAL index:DWORD
LOCAL keyName[256]:BYTE
LOCAL keyValue[256]:BYTE
LOCAL buffersize:DWORD
mov index,0

Invoke RegOpenKeyEx,HKEY_CURRENT_USER, ADDR sKey, NULL, KEY_READ,ADDR hKey
.If (eax== ERROR_SUCCESS )
  .If (hKey != NULL)
    mov buffersize,sizeof keyName
    Do:
    int 3
invoke RegEnumKeyEx,hKey, index, ADDR keyName, ADDR buffersize, NULL, NULL, NULL, NULL
             .if (eax!=ERROR_NO_MORE_ITEMS)
                mov buffersize,sizeof keyName
          invoke RegQueryValueEx, hKey, ADDR keyName, NULL, ADDR rtype,ADDR keyValue,ADDR buffersize
        invoke MessageBox, NULL,addr keyName, addr keyValue, MB_OK
                  inc index
                jmp Do
        .endif
           invoke RegCloseKey, hKey
      .EndIf   
.EndIf

Ret
DisplayRegistry EndP

Relvinian

Mario,

That is the correct result back from that registry key because there shouldn't (and at least on the three machines I checked here) there aren't any subkeys.

My first question is this:  Are you really trying to find subkeys for enumerate the values in that key? If you are trying to enumerate values, look at RegEnumValue API.

Relvinian

mariø

I need to enum the values, but I need the value Name too.
Im wrong, because I'm thinking that RegEnumKeyEx returns the value name...
Thanks.

Relvinian

Mario,

RegEnumValue will give you the field name and the data vailue for all field/value pairs in a specified key.

So if you are trying to get everything that is listed in the "Run" key, this is the API call you would be using to enumerate them.

RegEnumKeyEx will give you a list of subkeys from the specified key (basic example of this is a tree view style liisting).

Relvinian.