Microsoft.Win32.Registry Class

Provides Microsoft.Win32.RegistryKey objects that represent the root keys in the Windows registry, and static methods to access key/value pairs.

See Also: Registry Members


public static class Registry


This 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. For example, 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 instance, you can store color preferences, screen locations, or the size of the window. You can control this data for each user by storing the information in a different location in the registry.

The base, or root Microsoft.Win32.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:


Stores information about user preferences.


Stores configuration information for the local machine.


Stores information about types (and classes) and their properties.


Stores information about the default user configuration.


Stores performance information for software components.


Stores non-user-specific hardware information.


Stores dynamic data.

Once you have identified the root key under which you want to store/retrieve information from the registry, you can use the Microsoft.Win32.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

In the .NET Framework version 2.0, the Microsoft.Win32.Registry class also contains static Registry.GetValue(string, string, object) and erload:Microsoft.Win32.Registry.SetValue methods for setting and retrieving values from registry keys. These methods open and close registry keys each time they are used, so they do not perform as well as analogous methods in the Microsoft.Win32.RegistryKey class, when you access a large number of values.

The Microsoft.Win32.RegistryKey class also provides methods that allow you to set Windows access control security for registry keys, to test the data type of a value before retrieving it, and to delete keys.


Namespace: Microsoft.Win32
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,