LONG RegOpenKeyEx(hkey, lpszSubKey, fdwOptions, samDesired, phkResult) | |||||
HKEY hkey; | /* handle of an open key | */ | |||
LPTSTR lpszSubKey; | /* address of name of subkey to open | */ | |||
DWORD fdwOptions; | /* reserved | */ | |||
REGSAM samDesired; | /* desired security access mask | */ | |||
PHKEY phkResult; | /* address of handle of open key | */ |
The RegOpenKeyEx function opens the 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 to open. This parameter must not be NULL.
fdwOptions
This parameter is reserved.
samDesired
Specifies a security access mask that specifies the desired security access for the new key. This parameter may be some combination of the following values:
Value | Meaning |
KEY_ALL_ACCESS | ||
Combines query value, enumerate subkey, notify, create subkey and set value access. | ||
KEY_CREATE_SUB_KEY | ||
Permission to create subkeys. | ||
KEY_ENUMERATE_SUB_KEYS | ||
Permission to enumerate subkeys. | ||
KEY_EXECUTE | ||
Read access. | ||
KEY_NOTIFY | ||
Change notification will occur. | ||
KEY_QUERY_VALUE | ||
Permission to query subkey data. | ||
KEY_READ | ||
Combines query value, enumerate subkey, and notify access. | ||
KEY_SET_VALUE | ||
Permission to set subkey data. | ||
KEY_WRITE | ||
Combines set value and create subkey access. |
phkResult
Points to a variable that receives the handle of the opened key.
The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.
Unlike the RegCreateKeyEx function, the RegOpenKeyEx function does not create the specified key if the key does not exist in the database.
The RegOpenKeyEx 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).
RegOpenKey, RegCreateKeyEx