Jump to content
Sign in to follow this  
rameshk

Need Help in Reading Registry Subkeys..

Recommended Posts

rameshk

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.

Share this post


Link to post
Share on other sites
KJohn

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...

Share this post


Link to post
Share on other sites
KJohn

$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

Share this post


Link to post
Share on other sites
rameshk

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...

Share this post


Link to post
Share on other sites
KJohn

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.

Share this post


Link to post
Share on other sites
rameshk

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.