The RegEnumKeyEx function enumerates subkeys of the specified open registry key. The function retrieves information about one subkey each time it is called.
LONG RegEnumKeyEx( HKEY hKey, DWORD dwIndex, LPTSTR lpName, LPDWORD lpcName, LPDWORD lpReserved, LPTSTR lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime );
This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA
HKEY_USERS
Windows Me/98/95: This parameter can also be the following value:
HKEY_DYN_DATA
Because subkeys are not ordered, any new subkey will have an arbitrary index. This means that the function may return subkeys in any order.
For more information, see Registry Element Size Limits.
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.
Windows Server 2003, Windows XP/2000/NT: If the lpName buffer is too small to receive the name of the key, the function returns ERROR_MORE_DATA.
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. To retrieve the index of the last subkey, use the RegQueryInfoKey function.
While an application is using the RegEnumKeyEx function, it should not make calls to any registration functions that might change the key being enumerated.
For an example, see Enumerating Registry Subkeys.
Client: Requires Windows XP, Windows 2000 Professional,
Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server: Requires Windows Server 2003, Windows 2000 Server, or
Windows NT Server.
Unicode: Implemented as Unicode and ANSI versions. Note that Unicode
support on Windows Me/98/95 requires Microsoft
Layer for Unicode.
Header: Declared in Winreg.h; include Windows.h.
Library: Use Advapi32.lib.
Registry Overview, Registry Functions, RegCreateKeyEx, RegDeleteKey, RegOpenKeyEx, RegQueryInfoKey