Regopenkeyex: This function is used to open a specific registry key. The registry key value is case-insensitive.
This remote call interface also exists, and the function name is ceregopenkeyex
Long regopenkeyex (
Hkey,
Lpwstr lpsubkey,
DWORD uloptions,
Regsam samdesired,
Phkey phkresult
);
Parameters
Parameters
Hkey
Input parameter to identify the currentRegcreatekeyexOr the registry key handle opened by regopenkeyex, or the following pre-defined handle
Hkey_classes_root
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Lpsubkey
Input parameter, which points to a string used to save the name of the Registry to be opened. If this parameter is null or a pointer to an empty string, the function opens a key defined by the hkey. In this case, this function does not close the handle opened by the port wall.
Uloptions
Input parameter, reserved, set to 0
Samdesired
Input parameter. Indicates the permission to open the Registry. If the security descriptor of this parameter does not allow the current process to access the registry, the function returns a failure. For detailed security descriptions, see the following table:
Key_all_access (0xf003f) |
Combines the standard_rights_required, key_query_value, key_set_value, key_create_sub_key, key_enumerate_sub_keys, key_policy, and key_create_link access rights. |
Key_create_link (0x0020) |
Reserved for system use. |
Key_create_sub_key (0x0004) |
Required to create a subkey of a registry key. |
Key_enumerate_sub_keys (0x0008) |
Required to enumerate the subkeys of a registry key. |
Key_execute (0x20019) |
Equivalent to key_read. |
Key_notify (0x0010) |
Required to request change specifications for a registry key or for subkeys of a registry key. |
Key_query_value (0x0001) |
Required to query the values of a registry key. |
Key_read (0x20019) |
Combines the standard_rights_read, key_query_value, key_enumerate_sub_keys, and key_policy values. |
Key_set_value (0x0002) |
Required to create, delete, or set a registry value. |
Key_wow64_32key (0x0200) |
Indicates that an application on 64-bit windows shoshould operate on the 32-bit registry view. For more information, see accessing an alternate registry view. |
This flag must be combined using the OR operator with the other flags in this table that either query or access registry values. |
Key_wow64_64key (0x0100) |
Indicates that an application on 64-bit windows shoshould operate on the 64-bit registry view. For more information, see accessing an alternate registry view. |
This flag must be combined using the OR operator with the other flags in this table that either query or access registry values. |
Key_write (0x20006) |
Combines the standard_rights_write, key_set_value, and key_create_sub_key access rights. |
Phkresult
An output parameter pointing to a variable that is used to save the handle that opens the registry key. If the returned handle is no longer used, call regclosekey to close it.
Return Value:
Error_success indicates that the function is successfully executed, and a non-zero value indicates that the function fails to be executed. To obtain the error description, call the formatmessage function and input the format_message_from_system parameter.
Note:
Unlike regcreatekeyex, The regopenkeyex function does not create a new key when the key to be opened does not exist.
Requirements
Client |
Requires Windows "Longhorn", Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows ME, Windows 98, or Windows 95. |
Server |
Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 server, or Windows NT Server. |
Header |
Declared in winreg. h; Include windows. h. |
Library |
Link to advapi32.lib. |
DLL |
Requires advapi32.dll. |
Unicode |
ImplementedRegopenkeyexw(UNICODE) andRegopenkeyexa(ANSI). Note that Unicode support on Windows ME/98/95 requires Microsoft layer for Unicode. |