The Microsoft.Win32.Registry class
This article provides supplementary remarks to the reference documentation for this API.
The Registry class provides the set of standard root keys found in the registry on machines running Windows. The registry is a storage facility for information about applications, users, and default system settings. Applications can use the registry for storing information that needs to be preserved after the application is closed, and access that same information when the application is reloaded. For example, you can store color preferences, screen locations, or the size of a window. You can control this data for each user by storing the information in a different location in the registry.
The base, or root, RegistryKey instances that are exposed by the Registry
class delineate the basic storage mechanism for subkeys and values in the registry. All keys are read-only because the registry depends on their existence. The keys exposed by Registry
are:
Key | Description |
---|---|
CurrentUser | Stores information about user preferences. |
LocalMachine | Stores configuration information for the local machine. |
ClassesRoot | Stores information about types (and classes) and their properties. |
Users | Stores information about the default user configuration. |
PerformanceData | Stores performance information for software components. |
CurrentConfig | Stores non-user-specific hardware information. |
DynData | Stores dynamic data. |
Once you've identified the root key under which you want to store/retrieve information from the registry, you can use the RegistryKey class to add or remove subkeys and manipulate the values for a given key.
Hardware devices can place information in the registry automatically using the Plug and Play interface. Software for installing device drivers can place information in the registry by writing to standard APIs.
Static methods for getting and setting values
The Registry class also contains static
GetValue and SetValue methods for setting and retrieving values from registry keys. These methods open and close registry keys each time they're used. So when you access a large number of values, they don't perform as well as analogous methods in the RegistryKey class.
The RegistryKey class also provides methods that allow you to:
- Set Windows access control security for registry keys.
- Test the data type of a value before retrieving it.
- Delete keys.