RegEnumValue

  LONG RegEnumValue(hkey, iValue, lpszValue, lpcbValue, lpdwReserved, lpdwType, lpbData, lpcbData)    
  HKEY hkey; /* handle of key to query */
  DWORD iValue; /* index of value to query */
  LPTSTR lpszValue; /* address of buffer for value string */
  LPDWORD lpcbValue; /* size of value buffer */
  LPDWORD lpdwReserved; /* reserved; should be NULL */
  LPDWORD lpdwType; /* address of buffer for type code */
  LPBYTE lpbData; /* address of buffer for value data */
  LPDWORD lpcbData; /* size of data buffer */

The RegEnumValue function enumerates the values for an open configuration registry key. It does this by copying one indexed value name and data block for the specified key each time it is invoked.

Parameters

hkey

Identifies a currently open key or any of the following predefined reserved handle values:

HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS

The enumerated values are relative to the key specified by hkey.

iValue

Specifies the index of the value to retrieve. This parameter should be zero for the first call to the RegEnumValue function.

Values are not ordered. A new value has an arbitrary index. This means that this function may return values in any order.

lpszValue

Points to a buffer that receives the value name.

lpcbValue

Points to a variable that specifies the size of the buffer at lpszValue (in bytes). When the function returns, the variable at lpcbValue contains the number of bytes stored in the buffer.

lpdwReserved

Reserved; must be NULL.

lpdwType

Points to a variable that receives the type code for the value entry. The type code can be one of the following values:

Value Meaning

REG_BINARY  
  Freeform binary data.
REG_DWORD  
  A 32-bit number.
REG_DWORD_LITTLE_ENDIAN  
  A 32-bit number in little endian format (same as REG_DWORD).
REG_DWORD_BIG_ENDIAN  
  A 32-bit number in big endian format
REG_EXPAND_SZ  
  A null-terminated Unicode string that contains unexpanded references to environment variables (PATH, for example).
REG_LINK  
  A Unicode symbolic link.
REG_MULTI_SZ  
  An array of null-terminated strings, terminated by two null characters.
REG_NONE  
  No defined value type.
REG_RESOURCE_LIST  
  A device-driver resource list.
REG_SZ  
  A null-terminated Unicode string.

The lpdwType parameter may be NULL if the type code is not required.

lpbData

Points to a buffer that receives the data for the value entry. This parameter can be NULL if the data is not required.

lpcbData

Points to a variable that specifies the size of the buffer at lpbData (in bytes). When the function returns, the variable at lpcbData contains the number of bytes stored in the buffer. This parameter may only be NULL if lpbData is NULL.

Return Value

The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.

Comments

To enumerate values, an application should initially call the RegEnumValue function with the iValue parameter set to zero. The application should then increment the iValue parameter and call the RegEnumValue function until there are no more values (the function returns ERROR_CANT_READ).

While an application is using the RegEnumValue function it should not make calls to any registration functions that might change the key being queried. RegEnumValue will not function correctly otherwise.

The key specified by hkey must have been opened with KEY_QUERY_VALUE access. Use the RegCreateKeyEx or RegOpenKeyEx function to open the key.

To determine the maximum size of the name and data buffers, use the RegQueryInfoKey function.

The RegEnumValue function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

RegEnumKey, RegEnumKeyEx