RegEnumKeyEx

RegEnumKeyEx the subkeys of the specified open registry key.

Syntax

LONG RegEnumKeyEx(
    HKEY         hKey  ,
    DWORD        dwIndex,
    LPTSTR       lpName, 
    LPDWORD      lpcName, 
    LPDWORD      lpReserved, 
    LPTSTR       lpClass, 
    LPDWORD      lpcClass, 
    PFILETIME    lpftLastWriteTime 
  );

Parameters

hKey

A 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 RegCreateKey, RegCreateKeyEx, RegOpenKey or RegOpenKeyEx function. It can also be one of the following predefined keys:

HKEY_LOCAL_MACHINE

HKEY_USERS

dwIndex

The index of the subkey to retrieve. This parameter should be zero for the first call to the RegEnumKeyEx 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.

lpName

A pointer to a buffer that receives the name of the subkey, including the terminating null character. The function copies only the name of the subkey, not the full key hierarchy, to the buffer. If the function fails, no information is copied to this buffer.

lpcName

A pointer to a variable that specifies the size of the buffer specified by the lpName parameter, in characters. This size should include the terminating null character. If the function succeeds, the variable pointed to by lpcName contains the number of characters stored in the buffer, not including the terminating null character.

lpReserved

This parameter is reserved and must be NULL.

lpClass

This parameter is ignored under RTSS.

lpcClass

This parameter is ignored under RTSS.

lpftLastWriteTime

A pointer to FILETIME structure that receives the time at which the enumerated key was last written. This parameter is optional and can be NULL

Return Value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a system 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 RegEnumKeyEx function with the dwIndex parameter set to zero. The application should then increment the dwIndex parameter and call RegEnumKeyEx until there are no more subkeys (meaning the function returns ERROR_NO_MORE_ITEMS).

The application can also set dwIndex 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.

While an application is using the RegEnumKeyEx function, it should not make calls to any registration functions that might change the key being enumerated.

Requirements

Minimum Supported Version RTX64 2013
Header windows.h
Library Rtx_Rtss.lib

See Also:

Registry API

RegCreateKeyEx

RegDeleteKey

RegOpenKeyEx