RegEnumKeyExW function
Retrieves the name of a subkey under the specified open registry key and also retrieves the class, security, and extended attribute flags of the subkey.
Syntax
LSTATUS RegEnumKeyExW(
HKEY hKey,
DWORD dwIndex,
LPWSTR lpName,
LPDWORD lpcchName,
LPDWORD lpReserved,
LPWSTR lpClass,
LPDWORD lpcchClass,
PFILETIME lpftLastWriteTime
);
Parameters
hKey-
A handle to an open registry key. The key is assumed to have been opened with either the KEY_ENUMERATE_SUB_KEYS access right or KEY_READ access right.
A handle to an open registry key. The key is assumed to have been opened with either theKEY_ENUMERATE_SUB_KEYSaccess right orKEY_READaccess right. dwIndex-
The index of the subkey to retrieve. This parameter is a zero-based value. To retrieve the first subkey, set
dwIndexto 0; to retrieve the second, set it to 1, and so on. lpName- A pointer to a buffer that receives the null-terminated name of the subkey.
lpcchName-
A pointer to a variable that specifies the size of the buffer pointed to by
lpName, in characters. When the function returns, this variable contains the number of characters copied to the buffer, not including the terminating null character.
If the buffer pointed to bylpNameis not large enough to hold the subkey name, the function returnsERROR_MORE_DATA, and the variable pointed to bylpcchNamecontains the size of the buffer required to hold the subkey name, including the terminating null character. lpReserved-
This parameter is reserved and must be
NULL. lpClass-
A pointer to a buffer that receives the null-terminated class name of the subkey. This parameter can be
NULL. lpcchClass-
A pointer to a variable that specifies the size of the buffer pointed to by
lpClass, in characters. When the function returns, this variable contains the number of characters copied to the buffer, not including the terminating null character.
If the buffer pointed to bylpClassis not large enough to hold the class name, the function returnsERROR_MORE_DATA, and the variable pointed to bylpcchClasscontains the size of the buffer required to hold the class name, including the terminating null character. This parameter can beNULL. lpftLastWriteTime-
A pointer to a FILETIME structure that receives the last write time of the subkey. This parameter 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 defined in WinError.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.
Remarks
To enumerate subkeys of an open key, an application typically calls RegEnumKeyExW in a loop, incrementing the dwIndex parameter from 0 until the function returns ERROR_NO_MORE_ITEMS. The last error code set when there are no more subkeys is ERROR_NO_MORE_ITEMS.
The order in which the subkeys are enumerated is not guaranteed. If the application needs to process subkeys in a specific order, it must sort the subkey names after retrieving them.
The application must call the RegCloseKey function to close the handle to the registry key when it is no longer needed.
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Target Platform | Windows |
| Header | winreg.h |
| Library | Advapi32.lib |
| DLL | Advapi32.dll |