This documentation is archived and is not being maintained.

RegistryKey.GetValue Method

Retrieves the specified value.

Overload List

Retrieves the data associated with the specified value, or null if the value does not exist.

[Visual Basic] Overloads Public Function GetValue(String) As Object
[C#] public object GetValue(string);
[C++] public: Object* GetValue(String*);
[JScript] public function GetValue(String) : Object;

Retrieves the specified value, or the default value you provide if the specified value is not found.

[Visual Basic] Overloads Public Function GetValue(String, Object) As Object
[C#] public object GetValue(string, object);
[C++] public: Object* GetValue(String*, Object*);
[JScript] public function GetValue(String, Object) : Object;


[Visual Basic, C#, C++] This code example is part of a larger example provided for the RegistryKey class.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of GetValue. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
' Delete the non-secure password value.
testSettings = test9999.OpenSubKey("TestSettings", True)

' Verify the deletion.
Console.WriteLine(CType(testSettings.GetValue( _
    "password", "Password not found."), String))

    testSettings = test9999.OpenSubKey("TestSettings", true))
    // Delete the non-secure password value.

    // Verify the deletion.
        "password", "Password not found."));

// Delete the non-secure password value.
testSettings = test9999->OpenSubKey(S"TestSettings", true);

// Verify the deletion.
    testSettings->GetValue("password", S"Password not found.")));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

RegistryKey Class | RegistryKey Members | Microsoft.Win32 Namespace