Export (0) Print
Expand All

RegistryKey.CreateSubKey Method (String, RegistryKeyPermissionCheck, RegistryOptions)

Creates a subkey or opens a subkey for write access, using the specified permission check and registry options.

Namespace:  Microsoft.Win32
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(false)]
public RegistryKey CreateSubKey(
	string subkey,
	RegistryKeyPermissionCheck permissionCheck,
	RegistryOptions options
)

Parameters

subkey
Type: System.String

The name or path of the subkey to create or open.

permissionCheck
Type: Microsoft.Win32.RegistryKeyPermissionCheck

One of the enumeration values that specifies whether the key is opened for read or read/write access.

options
Type: Microsoft.Win32.RegistryOptions

The registry option to use; for example, that creates a volatile key.

Return Value

Type: Microsoft.Win32.RegistryKey
The newly created subkey, or null if the operation failed.

ExceptionCondition
ArgumentNullException

subkey is null.

ObjectDisposedException

The current RegistryKey object is closed (closed keys cannot be accessed).

UnauthorizedAccessException

The current RegistryKey object cannot be written to; for example, it was not opened as a writable key, or the user does not have the required access rights.

IOException

The nesting level exceeds 510.

-or-

A system error occurred, such as deletion of the key or an attempt to create a key in the LocalMachine root.

SecurityException

The user does not have the permissions required to create or open the registry key.

To obtain the current RegistryKey object, specify an empty string ("") for subkey.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft