Edit

Share via


RegistryProxy.GetValue(String, String, Object) Method

Definition

Gets a value from a registry key.

public:
 System::Object ^ GetValue(System::String ^ keyName, System::String ^ valueName, System::Object ^ defaultValue);
public object GetValue (string keyName, string valueName, object defaultValue);
member this.GetValue : string * string * obj -> obj
Public Function GetValue (keyName As String, valueName As String, defaultValue As Object) As Object

Parameters

keyName
String

String. Key from which the value is to be retrieved. Required.

valueName
String

String. Value to be retrieved. Required.

defaultValue
Object

Object. Default value to be supplied if the value does not exist. Required.

Returns

Gets a value from a registry key.

Exceptions

The user does not have the permissions required to read from the registry key.

The RegistryKey that contains the specified value has been marked for deletion.

keyName does not begin with a valid registry root.

Examples

This example reads the value Name from HKEY_CURRENT_USER\Software\MyApp and displays it in a MessageBox.

Dim readValue As Object
readValue = My.Computer.Registry.GetValue(
  "HKEY_CURRENT_USER\Software\MyApp", "Name", Nothing)
MsgBox("The value is " & CStr(readValue))

Remarks

valueName is not case-sensitive.

A registry key can contain 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 valueName.

The following table lists examples of tasks involving the GetValue method.

To See
Read a value from a registry key How to: Read a Value from a Registry Key

Applies to

See also