RegEnumKey

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

Syntax

Copy
LONG RegEnumKey(
    [in]    HKEY      hKey,
    [in]    DWORD     dwIndex,
    [out]   LPTSTR    lpname, 
    [in]    DWORD     cchName 
  );

Parameters

[in] hKey

A handle to an open registry key. The key must have been opened with the KEY_ENUMERATE_SUB_KEYS access to the key. This handle is returned by the RegCreateKey, RegCreateKeyEx, RegOpenKey or RegOpenKeyEx function, or it can be one of the following predefined keys:

[in] dwIndex

The index of the subkey of hKey to be retrieved. 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

[out] lpName

A pointer to a buffer that receives the name of the subkey, including the terminating null character. This function copies only the name of the subkey, not the full key hierarchy, to the buffer.

[in] cchName

Size of the buffer pointed to by lpName in TCHARs.

Return Value

If the function succeeds, it returns ERROR_SUCCESS. If the function fails, it returns a non-zero error code.

If there are no more subkeys available, the function returns ERROR_NO_MORE_ITEMS. If the lpName buffer is too small to receive the name of the key, the function returns ERROR_MORE_DATA.

Remarks

To enumerate subkeys, an application should initially call the RegEnumKey function with the dwIndex parameter set to zero. The application should then increment the dwIndex parameter and call the RegEnumKey function until there are no more subkeys (meaning the function returns ERROR_NO_MORE_ITEMS).

While an application is using the RegEnumKey function, it should not call any registration functions that might change the key being queried.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: