RegOpenKeyA function (winreg.h)
Opens the specified registry key.
LSTATUS RegOpenKeyA( [in] HKEY hKey, [in, optional] LPCSTR lpSubKey, [out] PHKEY phkResult );
[in, optional] lpSubKey
The name of the registry key to be opened. This key must be a subkey of the key identified by the hKey parameter.
Key names are not case sensitive.
If this parameter is NULL or a pointer to an empty string, the function returns the same handle that was passed in.
For more information, see Registry Element Size Limits.
A pointer to a variable that receives a handle to the opened key. If the key is not one of the predefined registry keys, call the RegCloseKey function after you have finished using the handle.
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different access right, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation.
RegOpenKey does not create the specified key if the key does not exist in the database.
If your service or application impersonates different users, do not use this function with HKEY_CURRENT_USER. Instead, call the RegOpenCurrentUser function.
The winreg.h header defines RegOpenKey as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||winreg.h (include Windows.h)|