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.

public:
 static Microsoft::Win32::RegistryKey ^ FromHandle(Microsoft::Win32::SafeHandles::SafeRegistryHandle ^ handle);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public static Microsoft.Win32.RegistryKey FromHandle (Microsoft.Win32.SafeHandles.SafeRegistryHandle handle);
static member FromHandle : Microsoft.Win32.SafeHandles.SafeRegistryHandle -> Microsoft.Win32.RegistryKey
Public Shared Function FromHandle (handle As SafeRegistryHandle) As RegistryKey

Parameters

handle
SafeRegistryHandle

The handle to the registry key.

Returns

A registry key.

Attributes

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.

public:
 static Microsoft::Win32::RegistryKey ^ FromHandle(Microsoft::Win32::SafeHandles::SafeRegistryHandle ^ handle, Microsoft::Win32::RegistryView view);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public static Microsoft.Win32.RegistryKey FromHandle (Microsoft.Win32.SafeHandles.SafeRegistryHandle handle, Microsoft.Win32.RegistryView view);
static member FromHandle : Microsoft.Win32.SafeHandles.SafeRegistryHandle * Microsoft.Win32.RegistryView -> Microsoft.Win32.RegistryKey
Public Shared Function FromHandle (handle As SafeRegistryHandle, view As RegistryView) As RegistryKey

Parameters

handle
SafeRegistryHandle

The handle to the registry key.

view
RegistryView

The registry view to use.

Returns

A registry key.

Attributes

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