LONG RegQueryValue(hkey, lpszSubKey, lpszValue, lpcbValue) | |||||
HKEY hkey; | /* handle of key to query | */ | |||
LPTSTR lpszSubKey; | /* address of name of subkey to query | */ | |||
LPTSTR lpszValue; | /* address of buffer for returned string | */ | |||
LPDWORD lpcbValue; | /* address of buffer for size of returned string | */ |
The RegQueryValue function retrieves the value name associated with a specified key.
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
lpszSubKey
Points to a null-terminated string specifying the name of the subkey of the hkey parameter for which the value is to be retrieved. If this parameter is NULL or points to an empty string, the function retrieves the value set by the RegSetValue function for the key specified by hkey.
lpszValue
Points to a buffer that receives the value name associated with lpszSubKey.
If the value name has type REG_EXPAND_SZ, this function expands the environment-variable names in the value name.
lpcbValue
Points to a variable specifying the size, in bytes, of the buffer at lpszValue.
When the function returns, this variable contains the size of the string copied to lpszValue, including the null-terminating character.
The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.
The key specified by hkey must have been opened with KEY_QUERY_VALUE access (KEY_READ access includes KEY_QUERY_VALUE access).
If the value name has type REG_SZ, REG_MULTI_SZ, or REG_EXPAND_SZ and the ANSI version of this function is used (either by explicitly calling RegQueryValueA or by not defining UNICODE before including windows.h), this function converts the stored Unicode string to an ANSI string before copying it to lpszValue.
The RegQueryValue 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).
RegEnumKey, RegEnumKeyEx, RegEnumValue, RegQueryValueEx, RegQueryInfoKey, RegSetValue, RegSetValueEx