AdvApi32RegOpenKeyEx(IntPtr, String, UInt32, Int32, IntPtr) Method

Opens the specified registry key. Note that key names are not case sensitive.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("AdvApi32.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static Win32ErrorCode RegOpenKeyEx(
	IntPtr hKey,
	string subKey,
	uint options,
	int samDesired,
	ref IntPtr refResult
)

Parameters

hKey  IntPtr
A handle to an open registry key.

This handle is returned by the RegCreateKeyEx or RegOpenKeyEx(SafeRegistryHandle, String, UInt32, Int32, IntPtr) function.

subKey  String
The name of the registry subkey to be opened.

Key names are not case sensitive.

The subKey parameter can be a pointer to an empty string.

If subKey is a pointer to an empty string and hKey is ClassesRoot, refResult receives the same hKey handle passed into the function. Otherwise, refResult receives a new handle to the key specified by hKey.

The subKey parameter can be only if hKey is one of the predefined keys.

If subKey is and hKey is ClassesRoot, refResult receives a new handle to the key specified by hKey. Otherwise, refResult receives the same hKey handle passed in to the function.

options  UInt32
Specifies the option to apply when opening the key.
samDesired  Int32
A mask that specifies the desired access rights to the key to be opened.

The function fails if the security descriptor of the key does not permit the requested access for the calling process.

refResult  IntPtr
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(SafeRegistryHandle) function after you have finished using the handle.

Return Value

Win32ErrorCode
If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is other Win32ErrorCode error code.

To get extended error information, call GetLastWin32Error.

Remarks

See Also