Enumerates the subkeys of the specified open registry key
#include <WinAPIReg.au3>
_WinAPI_RegEnumKey ( $hKey, $iIndex )
$hKey | Handle to an open registry key. The key must have been opened with the $KEY_ENUMERATE_SUB_KEYS access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS |
$iIndex | The index of the subkey to retrieve. This parameter should be zero for the first call to the _WinAPI_RegEnumKey() function and then incremented for subsequent calls. |
Success: | The string that contains the name of the subkey. |
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code. |
To enumerate subkeys, an application should initially call the _WinAPI_RegEnumKey() function with the $iIndex
parameter set to zero. The application should then increment the $iIndex parameter and call _WinAPI_RegEnumKey()
until there are no more subkeys (meaning the @extended flag sets to ERROR_NO_MORE_ITEMS (259)).
The application can also set $iIndex to the index of the last subkey on the first call to the function and
decrement the index until the subkey with the index 0 is enumerated. To retrieve the index of the last subkey,
use the _WinAPI_RegQueryInfoKey() function.
While an application is using the _WinAPI_RegEnumKey() function, it should not make calls to any registration
functions that might change the key being enumerated.
_WinAPI_RegCreateKey, _WinAPI_RegOpenKey, _WinAPI_RegQueryInfoKey
Search RegEnumKeyEx in MSDN Library.
#include <APIRegConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIError.au3>
#include <WinAPIReg.au3>
Local $hKey = _WinAPI_RegOpenKey($HKEY_CLASSES_ROOT, 'CLSID', $KEY_READ)
If @error Then
MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
Exit
EndIf
Local $iCount = _WinAPI_RegQueryInfoKey($hKey)
Local $aKey[$iCount[0]]
For $i = 0 To UBound($aKey) - 1
$aKey[$i] = _WinAPI_RegEnumKey($hKey, $i)
Next
_WinAPI_RegCloseKey($hKey)
_ArrayDisplay($aKey, '_WinAPI_RegEnumKey')