The RegEnumKey function

The RegEnumKey(keyPath, dwIndex) function:

The RegEnumKey function enumerates subkeys of the specified open registry key. The function retrieves the name of one subkey each time it is called.

dwIndex: Specifies the index of the subkey to retrieve. This value should be zero for the first call to the RegEnumKey function and then incremented for subsequent calls. Because subkeys are not ordered, any new subkey will have an arbitrary index. This means that the function may return subkeys in any order.

The five possible root keys are listed in the following table.
Root key NameAbbreviation
HKEY_CURRENT_USERHKCU
HKEY_LOCAL_MACHINEHKLM
HKEY_CLASSES_ROOTHKCR
HKEY_USERSHKEY_USERS
HKEY_CURRENT_CONFIGHKEY_CURRENT_CONFIG

Here's an example that reads a list of the registry keys:
// JScript
for (var i=0; i < 12; i++)
    Window.TextOut(0, 50, 50 + (i * 20), System.RegEnumKey("HKCR\\CLSID", i));
' VBScript
For i=0 To 12
    Window.TextOut 0, 50, 50 + (i * 20), System.RegEnumKey("HKCR\\CLSID", i)
Next
content
The new scripting host. It is not wscript.exe!
JScript and VBScript are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.