Retrieves the type and data for a specified name associated with an open registry subkey in a user-specific subtree (HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE).
LSTATUS SHRegQueryUSValueA( HUSKEY hUSKey, LPCSTR pszValue, DWORD *pdwType, void *pvData, DWORD *pcbData, BOOL fIgnoreHKCU, void *pvDefaultData, DWORD dwDefaultDataSize );
A handle to a currently open registry subkey, or one of the following predefined values. The subkey must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.
This handle can be obtained through the SHRegOpenUSKey function.
A pointer to the null-terminated string that contains the name of the value to be queried.
A pointer to the variable that sets or receives the key's value type. For more information, see Registry Data Types. This parameter can be NULL.
A pointer to the buffer that receives the value's data. This parameter can be NULL if the data is not required.
A pointer to the variable that specifies the size, in bytes, of the buffer pointed to by the pvData parameter. When the function returns, this variable contains the size of the data copied to pvData.
The variable that specifies which key to look under. When set to TRUE, SHRegQueryUSValue ignores HKEY_CURRENT_USER and returns the value from the key under HKEY_LOCAL_MACHINE.
A pointer to the default data.
The length, in bytes, of the default data.
Returns ERROR_SUCCESS if successful, or a nonzero error code defined in Winerror.h otherwise. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.
When fIgnoreHKCU is set to TRUE, SHRegQueryUSValue returns the value from the key under HKEY_LOCAL_MACHINE. When set to FALSE, SHRegQueryUSValue first tries to return the value from the key under HKEY_CURRENT_USER. However, if the key is not found under HKEY_CURRENT_USER, the value returns from the key under HKEY_LOCAL_MACHINE. If neither key is present, or if an error occurs and dwDefaultDataSize is nonzero, then the default data is copied to pvData and ERROR_SUCCESS returns. ERROR_SUCCESS returns for both default and non-default data, and there is no way of distinguishing which value copies to pvData. To prevent the use of default data, set pvDefaultData to NULL and dwDefaultDataSize to zero.
If you only need to read a single value, SHRegGetUSValue will both open the key and return the value. To use SHRegQueryUSValue, you must first open the key with SHRegOpenUSKey. However, once the key is opened, you can use SHRegQueryUSValue as many times as necessary. If you need to retrieve more than one value from the same key, using multiple calls to SHRegQueryUSValue is usually more efficient than SHRegGetUSValue, as the key is only opened once.
|Minimum supported client||Windows 2000 Professional, Windows XP [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|DLL||Shlwapi.dll (version 4.71 or later)|