Retrieves the type and data for a specified value name associated with an open registry key.
The key identified by hKey must have been opened with KEY_QUERY_VALUE access. To open the key, use RtRegCreateKeyEx or RtRegOpenKeyEx.
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 RtRegQueryValueEx or by not defining UNICODE before including the RTBASE.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 RtRegQueryValueEx 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 RtRegQueryValueEx, you should always expect to walk the returned data structure to look for the requested object.
LONG RtRegQueryValueEx( HKEY hKey, // handle to key to query LPTSTR lpValueName, // address of name of value to query LPDWORD lpReserved, // reserved LPDWORD lpType, // address of buffer for value type LPBYTE lpData, // address of data buffer LPDWORD lpcbData // address of data buffer size );
hKey
lpValueName
lpValueName
is NULL or an empty string, "", the call retrieves the type and data for the key's unnamed or default value, if any.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. |
lpType
parameter can be NULL if the type is not required.
lpData
lpcbData
lpData
parameter. When the call returns, this variable contains the size of the data copied to lpData
.lpcbData
also includes the size of the terminating null character.lpcbData
parameter can be NULL only if lpData is NULL.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 lpcbData
.lpData
is NULL, and lpcbData
is non-NULL, the call returns ERROR_SUCCESS, and stores the size of the data, in bytes, in the variable pointed to by lpcbData
. This lets an application determine the best way to allocate a buffer for the value's data.hKey
specifies HKEY_PERFORMANCE_DATA and the lpData
buffer is too small, RtRegQueryValueEx returns ERROR_MORE_DATA but lpcbData
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 RtRegQueryValueEx again passing the updated buffer size in the lpcbData
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 lpcbData
is unpredictable. ERROR_SUCCESS
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/rtbase.h | rt.h | rt.lib |
Registry system calls, RtRegCreateKeyEx, RtRegOpenKeyEx, RtRegEnumKeyEx, RtRegEnumValue, RtRegQueryInfoKey