Retrieves the type and data for a specified value name associated with an open registry key.
LONG RegQueryValueEx( HKEY hKey, LPTSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcData );
hKey
HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS HKEY_PERFORMANCE_DATA
lpValueName
If lpValueName is NULL or an empty string, "", the call retrieves the type and data for the key's unnamed or default value, if any.
Keys do not automatically have an unnamed or default value. Unnamed values can be of any type.
lpReserved
lpType
REG_BINARY |
Binary data in any form. |
REG_DWORD |
A 32-bit number. |
REG_DWORD_LITTLE_ENDIAN |
A 32-bit number in little-endian format. This is equivalent to REG_DWORD. |
REG_DWORD_BIG_ENDIAN |
A 32-bit number in big-endian format. |
REG_EXPAND_SZ |
A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It is either a Unicode or ANSI string, depending on whether you use the Unicode or ANSI calls. |
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 string. It is either a Unicode or ANSI string, depending on whether you use the Unicode or ANSI calls. |
If the type is not required, the lpType parameter can be NULL.
lpData
lpcData
lpData
parameter. When the call returns, this variable contains the size of the data copied to lpData
.
If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, then lpcData also includes the size of the terminating null character.
If lpData is NULL, the lpcData parameter can be NULL.
If the buffer specified by lpData parameter is not large enough to hold the data, the call returns the value ERROR_MORE_DATA, and stores the required buffer size, in bytes, into the variable pointed to by lpcData.
If lpData is NULL, and lpcData is non-NULL, the call returns ERROR_SUCCESS, and stores the size of the data, in bytes, in the variable pointed to by lpcData. An application can then determine the best way to allocate a buffer for the value's data.
If hKey specifies HKEY_PERFORMANCE_DATA and the lpData buffer is too small, RegQueryValueEx returns ERROR_MORE_DATA but lpcData does not return the required buffer size. This is because the size of the performance data can change from one call to the next. In this case, you must increase the buffer size and call RegQueryValueEx again passing the updated buffer size in the lpcData parameter. Repeat this until the call succeeds. You need to maintain a separate variable to keep track of the buffer size, because the value returned by lpcData is unpredictable.
The key identified by hKey must be opened with KEY_QUERY_VALUE access. To open the key, use RegCreateKeyEx or RegOpenKeyEx.
If the value data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, and the ANSI version of this call is used (either by explicitly calling RegQueryValueEx or by not defining UNICODE before including the RTREG.H file), this call converts the stored Unicode string to an ANSI string before copying it to the buffer pointed to by pData.
When calling RegQueryValueEx with hKey set to the HKEY_PERFORMANCE_DATA handle and a value string of a specified object, the returned data structure sometimes has unrequested objects. Don't be surprised; this is normal behavior. When calling RegQueryValueEx, you should always expect to walk the returned data structure to look for the requested object.
ERROR_SUCCESS
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/iwin32.h | iwin32.h iwin32rt.h |
rt.lib |
Note
This function operates in the real-time portion of your application.
RegCreateKeyEx, RegEnumKeyEx, RegEnumValue, RegOpenKeyEx, RegQueryInfoKey, iwin32 API, iwin32 Overview