<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />

RegistryKey

public sealed class RegistryKey : MarshalByRefObject, IDisposable
Represents a key-level node in the Windows registry. This class is a registry encapsulation.
public SafeRegistryHandle Handle { get; }

Gets a SafeRegistryHandle object that represents the registry key that the current RegistryKey object encapsulates.

public string Name { get; }

Retrieves the name of the key.

public int SubKeyCount { get; }

Retrieves the count of subkeys of the current key.

public int ValueCount { get; }

Retrieves the count of values in the key.

public RegistryView View { get; }

Gets the view that was used to create the registry key.

Creates a registry key from a specified handle.

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

Opens a new RegistryKey that represents the requested key on the local machine with the specified view.

public static RegistryKey OpenRemoteBaseKey(RegistryHive hKey, string machineName)

Opens a new RegistryKey that represents the requested key on a remote machine.

public static RegistryKey OpenRemoteBaseKey(RegistryHive hKey, string machineName, RegistryView view)

Opens a new registry key that represents the requested key on a remote machine with the specified view.

public void Close()

Closes the key and flushes it to disk if its contents have been modified.

public RegistryKey CreateSubKey(string subkey)

Creates a new subkey or opens an existing subkey for write access.

public RegistryKey CreateSubKey(string subkey, bool writable)

Creates a new subkey or opens an existing subkey with the specified access. Available starting with .NET Framework 4.6.

public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options)

Creates a new subkey or opens an existing subkey with the specified access. Available starting with .NET Framework 4.6.

public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck)

Creates a new subkey or opens an existing subkey for write access, using the specified permission check option.

public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, RegistrySecurity registrySecurity)

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

public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)

Creates a new subkey or opens an existing subkey for write access, using the specified permission check option and registry security.

public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)

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

public void DeleteSubKey(string subkey)

Deletes the specified subkey.

public void DeleteSubKey(string subkey, bool throwOnMissingSubKey)

Deletes the specified subkey, and specifies whether an exception is raised if the subkey is not found.

public void DeleteSubKeyTree(string subkey)

Deletes a subkey and any child subkeys recursively.

public void DeleteSubKeyTree(string subkey, bool throwOnMissingSubKey)

Deletes the specified subkey and any child subkeys recursively, and specifies whether an exception is raised if the subkey is not found.

public void DeleteValue(string name)

Deletes the specified value from this key.

public void DeleteValue(string name, bool throwOnMissingValue)

Deletes the specified value from this key, and specifies whether an exception is raised if the value is not found.

public void Dispose()

Releases all resources used by the current instance of the RegistryKey class.

public void Flush()

Writes all the attributes of the specified open registry key into the registry.

Returns the access control security for the current registry key.

Returns the specified sections of the access control security for the current registry key.

public string[] GetSubKeyNames()

Retrieves an array of strings that contains all the subkey names.

public object GetValue(string name)

Retrieves the value associated with the specified name. Returns null if the name/value pair does not exist in the registry.

public object GetValue(string name, object defaultValue)

Retrieves the value associated with the specified name. If the name is not found, returns the default value that you provide.

public object GetValue(string name, object defaultValue, RegistryValueOptions options)

Retrieves the value associated with the specified name and retrieval options. If the name is not found, returns the default value that you provide.

public RegistryValueKind GetValueKind(string name)

Retrieves the registry data type of the value associated with the specified name.

public string[] GetValueNames()

Retrieves an array of strings that contains all the value names associated with this key.

public RegistryKey OpenSubKey(string name)

Retrieves a subkey as read-only.

public RegistryKey OpenSubKey(string name, bool writable)

Retrieves a specified subkey, and specifies whether write access is to be applied to the key.

public RegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck)

Retrieves the specified subkey for read or read/write access.

public RegistryKey OpenSubKey(string name, RegistryRights rights)

Retrieves a subkey with the specified name and access rights. Available starting with .NET Framework 4.6.

public RegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights)

Retrieves the specified subkey for read or read/write access, requesting the specified access rights.

public void SetAccessControl(RegistrySecurity registrySecurity)

Applies Windows access control security to an existing registry key.

public void SetValue(string name, object value)

Sets the specified name/value pair.

public void SetValue(string name, object value, RegistryValueKind valueKind)

Sets the value of a name/value pair in the registry key, using the specified registry data type.