RegistryKey.FromHandle Method

Definition

Creates a registry key from a specified handle.

Overloads

FromHandle(SafeRegistryHandle)

Creates a registry key from a specified handle.

FromHandle(SafeRegistryHandle, RegistryView)

Creates a registry key from a specified handle and registry view setting.

FromHandle(SafeRegistryHandle)

Creates a registry key from a specified handle.

[System.Runtime.InteropServices.ComVisible(false)]
public static Microsoft.Win32.RegistryKey FromHandle (Microsoft.Win32.SafeHandles.SafeRegistryHandle handle);
Parameters
handle
SafeRegistryHandle

The handle to the registry key.

Returns

A registry key.

Exceptions

handle is null.

The user does not have the necessary registry rights.

The user does not have the permissions required to perform this action.

Security

SecurityCriticalAttribute
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

SecurityPermission
for the ability to access the specified registry key if it is a remote key. Associated enumeration: UnmanagedCode

FromHandle(SafeRegistryHandle, RegistryView)

Creates a registry key from a specified handle and registry view setting.

[System.Runtime.InteropServices.ComVisible(false)]
public static Microsoft.Win32.RegistryKey FromHandle (Microsoft.Win32.SafeHandles.SafeRegistryHandle handle, Microsoft.Win32.RegistryView view);
Parameters
handle
SafeRegistryHandle

The handle to the registry key.

view
RegistryView

The registry view to use.

Returns

A registry key.

Exceptions

view is invalid.

handle is null.

The user does not have the necessary registry rights.

The user does not have the permissions required to perform this action.

Remarks

The view parameter for this method is used in subsequent operations, such as opening subkeys.

If view is Registry64 but the machine is running a 32-bit operating system, the returned key will use the Registry32 view.

Security

SecurityCriticalAttribute
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

SecurityPermission
for the ability to access the specified registry key if it is a remote key. Associated enumeration: UnmanagedCode

Applies to