Function Reference


RegEnumKey

Reads the name of a subkey according to its instance.

RegEnumKey ( "keyname", instance )

Parameters

keyname The registry key to read.
instance The 1-based key instance to retrieve

Return Value

Success: the requested subkey name.
Failure: an empty string and sets the @error flag to non-zero.
@error: 1 = unable to open requested key
 2 = unable to open requested main key
 3 = unable to remote connect to the registry
-1 = unable to retrieve requested subkey (key instance out of range)

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

When running on 64-bit Windows if you want to enum a key specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

Related

RegDelete, RegEnumVal, RegWrite

Example

#include <MsgBoxConstants.au3>

Local $sSubKey = ""
For $i = 1 To 10
    $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", $i)
    If @error Then ExitLoop
    MsgBox($MB_SYSTEMMODAL, "SubKey #" & $i & " under HKLM\SOFTWARE: ", $sSubKey)
Next