Microsoft.Win32.RegistryKey.GetValue Method

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

Syntax

[System.Runtime.InteropServices.ComVisible(false)]
public object GetValue (string name, object defaultValue, RegistryValueOptions options)

Parameters

name
The name of the value to retrieve. This string is not case-sensitive.
defaultValue
The value to return if name does not exist.
options
One of the enumeration values that specifies optional processing of the retrieved value.

Returns

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

Remarks

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

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

Note:

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 name.

RegistryKey.GetValue(string, object, RegistryValueOptions) 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.

Requirements

Namespace: Microsoft.Win32
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0