정리

[Win32 API] RegEnumKeyEx

저장소/VC++

RegEnumKeyEx Function

Enumerates the subkeys of the specified open registry key. The function retrieves information about one subkey each time it is called.

LONG WINAPI RegEnumKeyEx(
  __in          HKEY hKey,
  __in          DWORD dwIndex,
  __out         LPTSTR lpName,
  __in_out      LPDWORD lpcName,
  LPDWORD lpReserved,
  __in_out      LPTSTR lpClass,
  __in_out      LPDWORD lpcClass,
  __out         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. For more information, see Registry Key Security and Access Rights.

This handle is returned by the RegCreateKeyEx, RegCreateKeyTransacted, RegOpenKeyEx, or RegOpenKeyTransacted 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

Windows Me/98/95:  This parameter can also be the following value:

HKEY_DYN_DATA

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.

For more information, see Registry Element Size Limits.

lpcName

A pointer to a variable that specifies the size of the buffer specified by the lpName parameter, in TCHARs. This size should include the terminating null character. When the function returns, the variable pointed to by lpcName contains the number of characters stored in the buffer. The count returned does not include 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 string of the enumerated subkey. This parameter can be NULL.

lpcClass

A pointer to a variable that specifies the size of the buffer specified by the lpClass parameter, in TCHARs. The size should include the terminating null character. When the function returns, lpcClass contains the number of characters stored in the buffer. The count returned does not include the terminating null character. This parameter can be NULL only if lpClass is NULL.

lpftLastWriteTime

A pointer to a variable that receives the time at which the enumerated subkey was last written. 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. 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. 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.

Note that operations that access certain registry keys are redirected. For more information, see Registry Virtualization and 32-bit and 64-bit Application Data in the Registry.

Example Code

For an example, see Enumerating Registry Subkeys.

Requirements

Client

Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.

Server

Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server.

Header

Declared in Winreg.h; include Windows.h.

Library

Use Advapi32.lib.

DLL

Requires Advapi32.dll.

Unicode

Implemented as RegEnumKeyExW (Unicode) and RegEnumKeyExA (ANSI).


'저장소 > VC++' 카테고리의 다른 글

[Win32 API] RegQueryInfoKey  (0) 2010.12.16
[Win32 API] Registry Element Size Limits  (0) 2010.12.16
[Win32 API] File Version  (0) 2010.11.09
[Win32 API] System Information Functions  (0) 2010.07.16
[Win32 API] Verifying the System Version  (0) 2010.07.16