Microsoft.Win32.RegistryKey.GetValue Method

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

Syntax

public object GetValue (string name)

Parameters

name
The name of the value to retrieve. This string is not case-sensitive.

Returns

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

Remarks

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.

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

Note:

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

Note:

The recommended way to retrieve data from the Registry.PerformanceData key is to use the System.Diagnostics.PerformanceCounter class rather than the erload:Microsoft.Win32.RegistryKey.GetValue method.

RegistryKey.GetValue(string) 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: 1.0.5000.0, 2.0.0.0, 4.0.0.0