Represents a key-level node in the Windows registry. This type is a registry encapsulation.
Inheritance hierarchy
Microsoft.
Namespace:Microsoft.Win32
Assembly: mscorlib (in)
property
name | illustrate |
---|---|
Handle | Get oneSafeRegistryHandleObject, which represents the registry key encapsulated by the current RegistryKey object. |
Name | The name of the search item. |
SubKeyCount | Searches the number of child items of the current item. |
ValueCount | Search the count of values in the item. |
View | Gets the view used to create the registry key. |
method
name | illustrate |
---|---|
Close | Close this item and refresh the item to disk if the contents of the item have been modified. |
CreateSubKey(String) | Create a new child or open an existing child for write access. |
CreateSubKey(String, RegistryKeyPermissionCheck) | Use the specified permission check option to create a new child or open an existing child for write access. |
CreateSubKey(String, RegistryKeyPermissionCheck, RegistryOptions) | Create or open a child for write access using the specified permission checking and registry options. |
CreateSubKey(String, RegistryKeyPermissionCheck, RegistrySecurity) | Create a new child with the specified permission checking options and registry security or open an existing child for write access. |
CreateSubKey(String, RegistryKeyPermissionCheck, RegistryOptions, RegistrySecurity) | Create or open a child for write access using the specified permission check options, registry options, and registry security. |
DeleteSubKey(String) | Delete the specified child. |
DeleteSubKey(String, Boolean) | Delete the specified child and specify whether an exception is raised if the child is not found. |
DeleteSubKeyTree(String) | Recursively delete children and any child children. |
DeleteSubKeyTree(String, Boolean) | Recursively deletes the specified child and any child child, and specifies whether an exception is raised when the child is not found. |
DeleteValue(String) | Removes the specified value from this item. |
DeleteValue(String, Boolean) | Remove the specified value from this item and specify whether an exception is raised if the value is not found. |
Dispose | Frees all resources occupied by the current instance of the RegistryKey class. |
Flush | Writes all the properties of the specified open registry key to the registry. |
FromHandle(SafeRegistryHandle) | Create a registry key based on the specified handle. |
FromHandle(SafeRegistryHandle, RegistryView) | Creates a registry key with the specified handle and registry view settings. |
GetAccessControl() | Returns the access control security of the current registry key. |
GetAccessControl(AccessControlSections) | Returns the specified part of the access control security of the current registry key. |
GetSubKeyNames | Retrieves a string array containing all child names. |
GetValue(String) | Searches the value associated with the specified name. If there is no name/value pair in the registry, return null. |
GetValue(String, Object) | Searches the value associated with the specified name. If no name is found, the default value you provide is returned. |
GetValue(String, Object, RegistryValueOptions) | Searches the value associated with the specified name and search options. If no name is found, the default value you provide is returned. |
GetValueKind | Retrieves the registry data type of the value associated with the specified name. |
GetValueNames | Retrieves an array of strings containing all the value names associated with this item. |
OpenBaseKey | Opens a new RegistryKey that uses the specified view to represent the requested item on the local computer. |
OpenRemoteBaseKey(RegistryHive, String) | Open a new RegistryKey, which represents the requested item on the remote computer. |
OpenRemoteBaseKey(RegistryHive, String, RegistryView) | Opens a new registry key that represents the requested entries on the remote computer using the specified view. |
OpenSubKey(String) | Retrieve children read-only. |
OpenSubKey(String, RegistryKeyPermissionCheck) | Retrieves the specified child for read or read/write access. |
OpenSubKey(String, Boolean) | Retrieves the specified child and specifies whether to apply write access to the item. |
OpenSubKey(String, RegistryKeyPermissionCheck, RegistryRights) | Retrieves the specified child for read or read/write access, requesting the specified access permissions. |
SetAccessControl | Apply Windows Access Control Security to an existing registry key. |
SetValue(String, Object) | Sets the specified name/value pair. |
SetValue(String, Object, RegistryValueKind) | Set the value of the name/value pair in the registry key using the specified registry data type. |
ToString | Searches the string representation of this item. (Rewrite()。) |
Remark
To get an instance of RegistryKey, useRegistryOne of the static members of the class.
The registry acts as a central repository of information for operating systems and applications on your computer. The registry is organized in a hierarchical form according to the logical order of the elements stored there (seeRegistry). When storing information in the registry, please select the appropriate location according to the type of information stored. Be sure to avoid corruption of information created by other applications because this will cause unexpected behavior to those applications and will also have adverse effects on your own applications.
Registry keys are organized in the basic unit of the registry and can be compared with the folders of File Explorer. Each specific registry key can have subkeys, just like there can be subfolders under a folder. As long as the user has the corresponding permissions and the registry key is not the base key or the next level of the base key, the registry key can be deleted. Each registry key can also have multiple values associated with it (one value is like a file) that are used to store information, for example, about applications installed on your computer. Each value stores specific information and can be retrieved or updated as needed. For example, you can create a RegistryKey for your company (under the entry HKEY_LOCAL_MACHINE\Software) and then create a child for each application created by your company. Each child holds information specific to the application, such as color settings, screen position and size, or recognizable file extensions.
Note that the information stored in the registry can be used by other applications and users, so do not use the registry to store secure data or critical application information.
warn |
---|
Do not use a way that may cause malicious programs to create thousands of meaningless children or key/value pairs when exposing RegistryKey objects. For example, the caller is not allowed to enter any key or value. |
Starting in .NET Framework 4, the length of the registry key is no longer limited to 255 characters.
This is all about this article about the RegistryKey class of C# operation registry. I hope it will be helpful to everyone's learning and I hope everyone will support me more.