RegistryKey::CreateSubKey Method (String^, RegistryKeyPermissionCheck, RegistryOptions, RegistrySecurity^)
Creates a subkey or opens a subkey for write access, using the specified permission check option, registry option, and registry security.
Assembly: mscorlib (in mscorlib.dll)
public: [ComVisibleAttribute(false)] RegistryKey^ CreateSubKey( String^ subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, RegistrySecurity^ registrySecurity )
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.
- registryOptions
-
Type:
Microsoft.Win32::RegistryOptions
The registry option to use.
- registrySecurity
-
Type:
System.Security.AccessControl::RegistrySecurity^
The access control security for the new subkey.
Return Value
Type: Microsoft.Win32::RegistryKey^The newly created subkey, or null if the operation failed.
| Exception | Condition |
|---|---|
| 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.
Available since 4.0