sam
sam

Reputation: 197

How to read the subkeys in registry

Hi I have the registry structure like below

HKLM
    SOFTWARE
        MYAPP
            VER1
            VER2
            VER3

like that list goes depending on how many patches I install on top of MYAPP. Now I want read VER1, VER2 ... and I want to capture last VERX. How can read the subkeys under MYAPP and find out last subkey.

Upvotes: 2

Views: 4266

Answers (1)

Kamil
Kamil

Reputation: 13931

Answer - how to read registry keys (not values).

From NSIS Scripting Reference

4.9.2.5 EnumRegKey

user_var(output) root_key subkey index

Set user variable $x with the name of the 'index'th registry key in root_key\Subkey. Valid values for root_key are listed under WriteRegStr. Returns an empty string if there are no more keys, and returns an empty string and sets the error flag if there is an error.

StrCpy $0 0
loop:
  EnumRegKey $1 HKLM Software $0
  StrCmp $1 "" done
  IntOp $0 $0 + 1
  MessageBox MB_YESNO|MB_ICONQUESTION "$1$\n$\nMore?" IDYES loop
done:

In your case:

EnumRegKey $1 HKLM "Software\MYAPP" $0 

Upvotes: 7

Related Questions