Jump to content

Need Help in Reading Registry Subkeys..


rameshk
 Share

Recommended Posts

Can anyone help me in reading all the subkeys under a registry key? i need to cycle through them and find the required subkey based on the data in it. Thanks in advance.

RegEnumKey ( "keyname", instance )

keyname The registry key to read.

instance The 1-based key instance to retrieve

Return Value

Success: Returns the requested subkey name..

Failure: Returns "" and sets the @error flag:

1 if unable to open requested key

-1 if unable to retrieve requested subkey (key instance out of range)

Does that answer your question?

Related: RegEnumVal

Read through the AutoIt Help file for more information...

Link to comment
Share on other sites

$i = 1
$key = RegEnumKey("keyname",$i);first subkey
While $key <> ""
    Msgbox(0,"SubKey number "&$i, $key) ;displays the subkey value
    $i = $i + 1
    $key = RegEnumKey("keyname",$i)  ;getting next subkey
Wend

Link to comment
Share on other sites

It answers partially... but, how to get the ubound value for instance parameter (when the number of subkeys are not known in advance?

RegEnumKey ( "keyname", instance )

keyname The registry key to read.

instance The 1-based key instance to retrieve

Return Value

Success: Returns the requested subkey name..

Failure: Returns "" and sets the @error flag:

1 if unable to open requested key

-1 if unable to retrieve requested subkey (key instance out of range)

Does that answer your question?

Related: RegEnumVal

Read through the AutoIt Help file for more information...

Link to comment
Share on other sites

It answers partially... but, how to get the ubound value for instance parameter (when the number of subkeys are not known in advance?

$ubound = 1
While RegEnumKey("keyname",$ubound) <> ""
    $ubound = $ubound + 1
Wend
$ubound = $ubound - 1;as it will fail in the last check

This is unnecessary code, I don't know of any other way to get the Ubound. Your code has to be adaptive as in the code snippet given previously.

Link to comment
Share on other sites

Thanks for all. The below code works fine for me...

$i = 1

$key = RegEnumKey("KeyName",$i);first subkey

While $key <> ""

Msgbox(0,"SubKey number "&$i, $key) ;displays the subkey value

$i = $i + 1

$key = RegEnumKey("KeyName",$i) ;getting next subkey

If @error = -1 Then

MsgBox(0, "Error", "Out of Range")

ExitLoop

EndIf

Wend

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...