mscorlib 1.0.5000.0 2.0.0.0 4.0.0.0 System.MarshalByRefObject System.IDisposable System.Runtime.InteropServices.ComVisible(true)

To get an instance of , use one of the static members of the class.

The registry acts as a central repository of information for the operating system and the applications on a computer. The registry is organized in a hierarchical format, based on a logical ordering of the elements stored within it (please see for the base-level items in this hierarchy). When storing information in the registry, select the appropriate location based on the type of information being stored. Be sure to avoid destroying information created by other applications, because this can cause those applications to exhibit unexpected behavior, and can also have an adverse effect upon your own application.

Registry keys are the base unit of organization in the registry, and can be compared to folders in File Explorer. A particular key can have subkeys, just as a folder can have subfolders. Each key can be deleted, as long as the user has the appropriate permissions to do so, and the key is not a base key or at the level directly under the base keys. Each key can also have multiple values associated with it (a value can be compared to a file), which are used to store the information — for example, information about an application installed on the computer. Each value holds one particular piece of information, which can be retrieved or updated when required. For instance, you can create a for your company, under the key HKEY_LOCAL_MACHINE\Software, and then a subkey for each application that your company creates. Each subkey holds the information specific to that application, such as color settings, screen location and size, or recognized file extensions.

Note that information stored in the registry is available to other applications and users, and therefore should not be used to store security data or critical application information.

Do not expose objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.

Starting in the net_v40_long, the length of a registry key is no longer limited to 255 characters.

Represents a key-level node in the Windows registry. This class is a registry encapsulation.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  Calling this method on system keys will have no effect, because system keys are never closed.

  This method does nothing if you call it on an instance of RegistryKey that is already closed.

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

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  Microsoft.Win32.RegistryKey ``

  In order to perform this action, the user must have permission at this level and below in the registry hierarchy.

  Do not expose objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.

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

  The newly created subkey, or null if the operation failed. If a zero-length string is specified for , the current object is returned.

  The name or path of the subkey to create or open. This string is not case-sensitive.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` ``

  In order to perform this action, the user must have permission at this level and below in the registry hierarchy.

  Do not expose objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.

  In order to use the method, you must have an instance of the class. To get an instance of , use one of the static members of the class.

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

  The newly created subkey, or null if the operation failed. If a zero-length string is specified for , the current object is returned.

  The name or path of the subkey to create or open. This string is not case-sensitive. One of the enumeration values that specifies whether the key is opened for read or read/write access.
- Method
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` `` ``

  To obtain the current object, specify an empty string ("") for .

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

  The newly created subkey, or null if the operation failed.

  The name or path of the subkey to create or open. One of the enumeration values that specifies whether the key is opened for read or read/write access. The registry option to use; for example, that creates a volatile key.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` `` ``

  The method creates a registry key that has the access control specified by the parameter. The object that is returned represents the registry key, but that object is not restricted by the access control specified in the parameter.

  If is , the key is opened for read/write access. If is , the key is opened for read access.

  For backward compatibility, the key is opened for reading and writing if is and the parent key also has . If the parent key has any other setting, read/write status is controlled by the parent key's setting.

  In order to perform this action, the user must have permissions at this level and below in the registry hierarchy.

  Do not expose objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.

  In order to use the method, you must have an instance of the class. To get an instance of , use one of the static members of the class.

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

  The newly created subkey, or null if the operation failed. If a zero-length string is specified for , the current object is returned.

  The name or path of the subkey to create or open. This string is not case-sensitive. One of the enumeration values that specifies whether the key is opened for read or read/write access. The access control security for the new key.
- Method
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` `` `` ``

  To obtain the current object, specify an empty string ("") for .

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

  The newly created subkey, or null if the operation failed.

  The name or path of the subkey to create or open. One of the enumeration values that specifies whether the key is opened for read or read/write access. The registry option to use. The access control security for the new subkey.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  To delete child subkeys, use .

  Use caution when deleting registry keys.

  Deletes the specified subkey.

  The name of the subkey to delete. This string is not case-sensitive.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  To delete child subkeys, use .

  Use caution when deleting registry keys.

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

  The name of the subkey to delete. This string is not case-sensitive. Indicates whether an exception should be raised if the specified subkey cannot be found. If this argument is true and the specified subkey does not exist, an exception is raised. If this argument is false and the specified subkey does not exist, no action is taken.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  You must have appropriate permissions to delete the subkey and its tree.

  Deleting a particular key will remove all entries below the key in the tree. No warning will be provided. If you want to delete a subkey only when it has no child subkeys, use the method.

  Deletes a subkey and any child subkeys recursively.

  The subkey to delete. This string is not case-sensitive.
- Method
  4.0.0.0
  System.Void `` `` To be added.

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

  The name of the subkey to delete. This string is not case-sensitive. Indicates whether an exception should be raised if the specified subkey cannot be found. If this argument is true and the specified subkey does not exist, an exception is raised. If this argument is false and the specified subkey does not exist, no action is taken.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  On Windows 95, Windows 98, Windows 98 Second Edition, and Windows Millennium Edition, specifying an empty string for the parameter does not delete the default value.

  Deletes the specified value from this key.

  The name of the value to delete.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  If is false, there is no way to tell if the deletion was successful, without subsequently trying to access the value just deleted. Therefore, use caution when deleting values from the registry in this manner.

  On Windows 95, Windows 98, Windows 98 Second Edition, and Windows Millennium Edition, specifying an empty string for the parameter does not delete the default value.

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

  The name of the value to delete. Indicates whether an exception should be raised if the specified value cannot be found. If this argument is true and the specified value does not exist, an exception is raised. If this argument is false and the specified value does not exist, no action is taken.
- Method
  4.0.0.0
  System.Void

  Call Dispose when you are finished using the . The Dispose method leaves the in an unusable state. After calling Dispose, you must release all references to the so the garbage collector can reclaim the memory that the was occupying.

  For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.

  Always call Dispose before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's Finalize method.

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

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  It is not necessary to call Flush to write out changes to a key. Registry changes are flushed to disk when the registry uses its lazy flusher. Lazy flushing occurs automatically and regularly after a system-specified time interval. Registry changes are also flushed to disk at system shutdown.

  Unlike , the Flush function returns only when all the data has been written to the registry.

  The Flush function might also write out parts of or all of the other keys. Calling this function excessively can have a negative effect on an application's performance.

  An application should only call Flush if it must be absolute certain that registry changes are recorded to disk. In general, Flush rarely, if ever, need be used.

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

- Method
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` To be added.

  Creates a registry key from a specified handle.

  A registry key.

  The handle to the registry key.
- Method
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` ``

  The parameter for this method is used in subsequent operations, such as opening subkeys.

  If is but the machine is running a 32-bit operating system, the returned key will use the view.

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

  A registry key.

  The handle to the registry key. The registry view to use.
- Method
  2.0.0.0
  4.0.0.0
  System.Security.AccessControl.RegistrySecurity

  This method overload is equivalent to calling the method overload with the bitwise combination of the following flags: , , and . You can use that overload to search for other permissions.

  The user must have rights to call this method.

  Returns the access control security for the current registry key.

  An object that describes the access control permissions on the registry key represented by the current .

- Method
  2.0.0.0
  4.0.0.0
  System.Security.AccessControl.RegistrySecurity ``

  To request the access permissions currently granted to users, specify the bitwise combination of the following flags: , , and . Alternatively, you can use the method overload, which specifies exactly that combination of values.

  The user must have rights to call this method.

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

  An object that describes the access control permissions on the registry key represented by the current .

  A bitwise combination of enumeration values that specifies the type of security information to get.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String[]

  This method does not recursively find names. It returns the names on the base level from which it was called.

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

  An array of strings that contains the names of the subkeys for the current key.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To retrieve this unnamed value, specify either null or the empty string ("") for .

  When the method retrieves expandable string values (), it expands environment strings using data from the local environment. To retrieve expandable string values from the registry on a remote computer, use the method overload to specify that you do not want environment strings expanded.

  If a value containing expandable references to environment variables has been stored as a string (), rather than as an expandable string (), does not expand it. You can expand such a string after it has been retrieved by calling the method.

  The recommended way to retrieve data from the key is to use the class rather than the method.

  does not support reading values of type REG_NONE or REG_LINK. In both cases, the default value (null) is returned instead of the actual value.

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

  The value associated with , or null if is not found.

  The name of the value to retrieve. This string is not case-sensitive.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` ``

  Use this overload of to handle the case where a name does not exist yet — for example, the first time your application is run. Whenever you call this overload, use the parameter to specify the value to return if does not exist.

  A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To retrieve this unnamed value, specify either null or the empty string ("") for .

  When the method retrieves expandable string values (), it expands environment strings using data from the local environment. To retrieve expandable string values from the registry on a remote computer, use the overload to specify that you do not want environment strings expanded.

  If a value containing expandable references to environment variables has been stored as a string (), rather than as an expandable string (), the method does not expand it. You can expand such a string after it has been retrieved by calling the method.

  The recommended way to retrieve data from the key is to use the class rather than the method.

  does not support reading values of type REG_NONE or REG_LINK. In both cases, the default value (null) is returned instead of the actual value.

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

  The value associated with , with any embedded environment variables left unexpanded, or if is not found.

  The name of the value to retrieve. This string is not case-sensitive. The value to return if does not exist.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Object `` `` ``

  Use this overload to specify special processing of the retrieved value. For example, you can specify when retrieving a registry value of type to retrieve the string without expanding embedded environment variables.

  Use the parameter to specify the value to return if does not exist.

  A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To retrieve this unnamed value, specify either null or the empty string ("") for .

  does not support reading values of type REG_NONE or REG_LINK. In both cases, the default value (null) is returned instead of the actual value.

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

  The value associated with , processed according to the specified , or if is not found.

  The name of the value to retrieve. This string is not case-sensitive. The value to return if does not exist. One of the enumeration values that specifies optional processing of the retrieved value.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryValueKind ``

  A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To retrieve the registry data type of this unnamed value, specify either null or the empty string ("") for .

  For a description of supported registry data types, please see the enumeration.

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

  The registry data type of the value associated with .

  The name of the value whose registry data type is to be retrieved. This string is not case-sensitive.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String[]

  If no value names for the key are found, an empty array is returned.

  A registry key can have a default value — that is, a name/value pair in which the name is the empty string (""). If a default value has been set for a registry key, the array returned by the method includes the empty string.

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

  An array of strings that contains the value names for the current key.

- Property
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.SafeHandles.SafeRegistryHandle To be added. To be added.

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

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The name of the key includes the absolute path of this key in the registry, always starting at a base key, for example, HKEY_LOCAL_MACHINE.

  Retrieves the name of the key.

- Method
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` `` To be added.

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

  The requested registry key.

  The HKEY to open. The registry view to use.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  Microsoft.Win32.RegistryKey `` ``

  The local machine registry is opened if is . The requested key must be a root key on the remote machine, and is identified by the appropriate value.

  In order for a key to be opened remotely, both the server and client machines must be running the remote registry service, and have remote administration enabled.

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

  The requested registry key.

  The HKEY to open, from the enumeration. The remote machine.
- Method
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` `` ``

  The local machine registry is opened if is . The requested key must be a root key on the remote machine, and is identified by the appropriate value.

  In order for a key to be opened remotely, both the server and client machines must be running the remote registry service, and have remote administration enabled.

  On the 64-bit versions of Windows, portions of the registry are stored separately for 32-bit and 64-bit applications. There is a 32-bit view for 32-bit applications and a 64-bit view for 64-bit applications. If is but the remote machine is running a 32-bit operating system, the returned key will use the view.

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

  The requested registry key.

  The HKEY to open from the enumeration.. The remote machine. The registry view to use.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  Microsoft.Win32.RegistryKey ``

  You must open a key before it can be manipulated with other methods and properties. To modify a key, you must open it with an overload of the method that allows you to specify write access, such as the overload or the overload.

  If the specified subkey cannot be found, then null is returned.

  In order to use the method, you must have an instance of . To get an instance of , use the one of the static members of the class.

  Retrieves a subkey as read-only.

  The subkey requested, or null if the operation failed.

  The name or path of the subkey to open as read-only.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` ``

  Rather than throwing an exception, this method returns null if the requested key does not exist.

  If is , the key is opened for reading and writing; if is or , the key is opened for reading unless the parent key was opened with .

  In order to use the method, you must have an instance of the class. To get an instance of , use one of the static members of the class.

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

  The subkey requested, or null if the operation failed.

  The name or path of the subkey to create or open. One of the enumeration values that specifies whether the key is opened for read or read/write access.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  Microsoft.Win32.RegistryKey `` ``

  If the requested key does not exist, this method returns null instead of throwing an exception.

  If is true, the key will be opened for reading and writing, otherwise, the key will be opened as read-only.

  In order to use the method, you must have an instance of the method. To get an instance of , use one of the static members of the class.

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

  The subkey requested, or null if the operation failed.

  Name or path of the subkey to open. Set to true if you need write access to the key.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryKey `` `` ``

  Rather than throwing an exception, this method returns null if the requested key does not exist.

  If is , the key is opened for reading and writing; if is or , the key is opened for reading unless the parent key was opened with .

  The access specified for takes precedence over the access specified for . For example, if you specify for and for , an attempt to write to the subkey throws an exception.

  In order to use the method, you must have an instance of the class. To get an instance of , use one of the static members of the class.

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

  The subkey requested, or null if the operation failed.

  The name or path of the subkey to create or open. One of the enumeration values that specifies whether the key is opened for read or read/write access. A bitwise combination of enumeration values that specifies the desired security access.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  To modify permissions for a registry key, use the method to obtain a object representing the existing Windows access control security, modify that object, and then use the method to update security for the key.

  The object specified for replaces the existing security for the registry key. To add permissions for a new user, use the method to obtain the existing access control security, and then modify it.

  Applies Windows access control security to an existing registry key.

  The access control security to apply to the current subkey.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  Because many values can be stored in each key in the registry, you must use the parameter to specify the particular value you want to set.

  A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To set this unnamed value, specify either null or the empty string ("") for .

  In order to set values in a key, you must open the key with write access. After you have opened a key with write access, you can change any of the name/value pairs in that key.

  If the specified does not exist in the key, it is created and the associated value is set to .

  This overload of stores 64-bit integers as strings (). To store 64-bit numbers as values, use the overload that specifies .

  This overload of stores all string values as , even if they contain expandable references to environment variables. To save string values as expandable strings (), use the overload that specifies .

  Numeric types other than 32-bit integers are stored as strings by this method overload. Enumeration elements are stored as strings containing the element names.

  Do not expose objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.

  On Windows 98 and Windows Millennium Edition the registry is not Unicode, and not all Unicode characters are valid for all code pages. A Unicode character that is invalid for the current code page is replaced by the best available match. No exception is thrown.

  Sets the specified name/value pair.

  The name of the value to store. The data to be stored.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Void `` `` ``

  Because many values can be stored in each key in the registry, you must use the parameter to specify the particular value you want to set.

  A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To set this unnamed value, specify either null or the empty string ("") for .

  In order to set values in a key, you must open the key with write access. After you have opened a key with write access, you can change any of the name/value pairs in that key.

  If the specified does not exist in the key, it is created, and the associated value is set to .

  Specifying the registry data type is the same as using the overload.

  If the type of the specified does not match the specified , and the data cannot be converted, is thrown. For example, you can store a as a , but only if its value is less than the maximum value of a . You cannot store a single string value as a .

  If boxed values are passed for or , the conversion is done using the invariant culture.

  Do not expose objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.

  On Windows 98 and Windows Millennium Edition the registry is not Unicode, and not all Unicode characters are valid for all code pages. A Unicode character that is invalid for the current code page is replaced by the best available match. No exception is thrown.

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

  The name of the value to be stored. The data to be stored. The registry data type to use when storing the data.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  This property does not recursively count names. It only returns the count of names on the base level from which it was called.

  Retrieves the count of subkeys of the current key.

- Method
  System.Void

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  Releases all resources used by the .

  1.0.5000.0
  2.0.0.0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The return value includes the registry path of the specified key and the hexadecimal value for the key. The registry path includes the absolute root of the specified key, always starts at one of the base keys for the registry, for example, HKEY_LOCAL_MACHINE.

  Retrieves a string representation of this key.

  A string representing the key. If the specified key is invalid (cannot be found) then null is returned.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  Each registry key has a default value that is not associated with any name. This unnamed value can be set by using the method and specifying either null or the empty string ("") for . If the default value has never been set, it does not contribute to the total count returned by the property; once it has been set, however, it is always counted.

  Retrieves the count of values in the key.

- Property
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  Microsoft.Win32.RegistryView To be added.

  On the 64-bit versions of Windows, portions of the registry are stored separately for 32-bit and 64-bit applications. There is a 32-bit view for 32-bit applications and a 64-bit view for 64-bit applications.

  Do not assume that the view always corresponds to the actual view of the .

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