RegistryKey.GetValue 메서드

정의

지정된 이름과 연결된 값을 검색합니다.

오버로드

GetValue(String, Object, RegistryValueOptions)

지정된 이름 및 검색 옵션과 연결된 값을 검색합니다. 이름이 없으면 사용자가 제공하는 기본값을 반환합니다.

GetValue(String)

지정된 이름과 연결된 값을 검색합니다. 이름/값 쌍이 레지스트리에 없으면 null을 반환합니다.

GetValue(String, Object)

지정된 이름과 연결된 값을 검색합니다. 이름이 없으면 사용자가 제공하는 기본값을 반환합니다.

GetValue(String, Object, RegistryValueOptions)

Source:
RegistryKey.cs

지정된 이름 및 검색 옵션과 연결된 값을 검색합니다. 이름이 없으면 사용자가 제공하는 기본값을 반환합니다.

public:
 System::Object ^ GetValue(System::String ^ name, System::Object ^ defaultValue, Microsoft::Win32::RegistryValueOptions options);
public object GetValue (string name, object defaultValue, Microsoft.Win32.RegistryValueOptions options);
public object? GetValue (string? name, object? defaultValue, Microsoft.Win32.RegistryValueOptions options);
[System.Runtime.InteropServices.ComVisible(false)]
public object GetValue (string name, object defaultValue, Microsoft.Win32.RegistryValueOptions options);
member this.GetValue : string * obj * Microsoft.Win32.RegistryValueOptions -> obj
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.GetValue : string * obj * Microsoft.Win32.RegistryValueOptions -> obj
Public Function GetValue (name As String, defaultValue As Object, options As RegistryValueOptions) As Object

매개 변수

name
String

검색할 값의 이름입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

defaultValue
Object

name이 없는 경우에 반환할 값입니다.

options
RegistryValueOptions

검색된 값의 선택적인 처리를 지정하는 열거형 값 중 하나입니다.

반환

지정된 name에 따라 처리되는 options과 연결된 값이거나, defaultValue이 없으면 name입니다.

특성

예외

사용자가 레지스트리 키를 읽는 데 필요한 사용 권한이 없는 경우

지정된 값이 포함된 RegistryKey가 닫힌 경우. 닫힌 키는 액세스할 수 없습니다.

지정된 값이 포함된 RegistryKey가 삭제 표시된 경우

options가 유효한 RegistryValueOptions 값이 아닌 경우. 예를 들어, 잘못된 값이 RegistryValueOptions로 캐스팅되었습니다.

사용자에게 필요한 레지스트리 권한이 없는 경우

예제

다음 코드 샘플에서는 테스트 키를 만들고, 포함된 환경 변수를 사용하여 값을 추가하고, 확장된 형식과 확장되지 않은 형식 모두에서 값을 검색합니다.

#using <Microsoft.VisualBasic.dll>

using namespace System;
using namespace Microsoft::Win32;
using namespace Microsoft::VisualBasic;

int main()
{
    // Delete and recreate the test key.
    Registry::CurrentUser->DeleteSubKey( L"RegistryValueOptionsExample", false );
    RegistryKey ^ rk = 
        Registry::CurrentUser->CreateSubKey( L"RegistryValueOptionsExample" );
   
    // Add a value that contains an environment variable.
    rk->SetValue( L"ExpandValue", L"The path is %PATH%", 
        RegistryValueKind::ExpandString );
   
    // Retrieve the value, first without expanding the environment
    // variable and then expanding it.
    Console::WriteLine( L"Unexpanded: \"{0}\"", 
                        rk->GetValue( L"ExpandValue", 
                        L"No Value", 
                        RegistryValueOptions::DoNotExpandEnvironmentNames ) );
    Console::WriteLine( L"Expanded: \"{0}\"", rk->GetValue( L"ExpandValue" ) );
 
    return 0;
} //Main
using System;
using Microsoft.Win32;
using Microsoft.VisualBasic;

public class Example
{
    public static void Main()
    {
        // Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueOptionsExample", false);
        RegistryKey rk =
            Registry.CurrentUser.CreateSubKey("RegistryValueOptionsExample");

        // Add a value that contains an environment variable.
        rk.SetValue("ExpandValue", "The path is %PATH%", RegistryValueKind.ExpandString);

        // Retrieve the value, first without expanding the environment
        // variable and then expanding it.
        Console.WriteLine("Unexpanded: \"{0}\"",
            rk.GetValue("ExpandValue", "No Value",
            RegistryValueOptions.DoNotExpandEnvironmentNames));
        Console.WriteLine("Expanded: \"{0}\"", rk.GetValue("ExpandValue"));
    } //Main
} //Example
Imports Microsoft.Win32

Public Class Example
    Public Shared Sub Main()
        ' Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueOptionsExample", False)
        Dim rk As RegistryKey = _
            Registry.CurrentUser.CreateSubKey("RegistryValueOptionsExample")

        ' Add a value that contains an environment variable.
        rk.SetValue("ExpandValue", "The path is %PATH%", _
            RegistryValueKind.ExpandString)

        ' Retrieve the value, first without expanding the environment 
        ' variable and then expanding it.
        Console.WriteLine("Unexpanded: ""{0}""", _
            rk.GetValue("ExpandValue", "No Value", _
            RegistryValueOptions.DoNotExpandEnvironmentNames))
        Console.WriteLine("Expanded: ""{0}""", rk.GetValue("ExpandValue"))
    End Sub
End Class

설명

검색된 값의 특수 처리를 지정하려면 이 오버로드를 사용합니다. 예를 들어 형식 RegistryValueKind.ExpandString 의 레지스트리 값을 검색할 때 를 지정 RegistryValueOptions.DoNotExpandEnvironmentNames 하여 포함된 환경 변수를 확장하지 않고 문자열을 검색할 수 있습니다.

매개 변수를 defaultValue 사용하여 가 없으면 name 반환할 값을 지정합니다.

참고

레지스트리 키에는 이름과 연결되지 않은 값이 하나 있을 수 있습니다. 레지스트리 편집기에서 명명 되지 않은 값이 표시 되 면 "(기본값)" 문자열 이름 대신 표시 됩니다. 이 명명되지 않은 값을 검색하려면 에 또는 null 빈 문자열("")을 지정합니다 name.

GetValue 는 형식 REG_NONE 또는 REG_LINK 값을 읽는 것을 지원하지 않습니다. 두 경우 모두 실제 값 대신 기본값(null)이 반환됩니다.

추가 정보

적용 대상

GetValue(String)

Source:
RegistryKey.cs

지정된 이름과 연결된 값을 검색합니다. 이름/값 쌍이 레지스트리에 없으면 null을 반환합니다.

public:
 System::Object ^ GetValue(System::String ^ name);
public object GetValue (string name);
public object? GetValue (string? name);
member this.GetValue : string -> obj
Public Function GetValue (name As String) As Object

매개 변수

name
String

검색할 값의 이름입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

반환

name과 연결된 값이거나, name이 없으면 null입니다.

예외

사용자가 레지스트리 키를 읽는 데 필요한 사용 권한이 없는 경우

지정된 값이 포함된 RegistryKey가 닫힌 경우. 닫힌 키는 액세스할 수 없습니다.

지정된 값이 포함된 RegistryKey가 삭제 표시된 경우

사용자에게 필요한 레지스트리 권한이 없는 경우

예제

다음 코드 예제에서는 테스트 키를 만들고 키에 다른 데이터 형식의 값을 추가합니다. 그런 다음, 이름/값 쌍을 읽고 메서드를 사용하여 GetValueKind 해당 레지스트리 데이터 형식을 검색하여 콘솔에 표시합니다.

using namespace System;
using namespace Microsoft::Win32;
int main()
{
   
   // Delete and recreate the test key.
   Registry::CurrentUser->DeleteSubKey( "RegistryValueKindExample", false );
   RegistryKey ^ rk = Registry::CurrentUser->CreateSubKey( "RegistryValueKindExample" );
   
   // Create name/value pairs.
   // This overload supports QWord (long) values. 
   rk->SetValue( "QuadWordValue", 42, RegistryValueKind::QWord );
   
   // The following SetValue calls have the same effect as using the
   // SetValue overload that does not specify RegistryValueKind.
   //
   rk->SetValue( "DWordValue", 42, RegistryValueKind::DWord );
   rk->SetValue( "MultipleStringValue", gcnew array<String^>{
      "One","Two","Three"
   }, RegistryValueKind::MultiString );
   rk->SetValue( "BinaryValue", gcnew array<Byte>{
      10,43,44,45,14,255
   }, RegistryValueKind::Binary );
   rk->SetValue( "StringValue", "The path is %PATH%", RegistryValueKind::String );
   
   // This overload supports setting expandable string values. Compare
   // the output from this value with the previous string value.
   rk->SetValue( "ExpandedStringValue", "The path is %PATH%", RegistryValueKind::ExpandString );
   
   // Display all the name/value pairs stored in the test key, with the
   // registry data type in parentheses.
   //
   array<String^>^valueNames = rk->GetValueNames();
   System::Collections::IEnumerator^ myEnum = valueNames->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ s = safe_cast<String^>(myEnum->Current);
      RegistryValueKind rvk = rk->GetValueKind( s );
      switch ( rvk )
      {
         case RegistryValueKind::MultiString:
         {
            array<String^>^values = (array<String^>^)rk->GetValue( s );
            Console::Write( "\r\n {0} ({1}) =", s, rvk );
            for ( int i = 0; i < values->Length; i++ )
            {
               if (i != 0) Console::Write(",");
               Console::Write( " \"{0}\"", values[ i ] );

            }
            Console::WriteLine();
            break;
         }
         case RegistryValueKind::Binary:
         {
            array<Byte>^bytes = (array<Byte>^)rk->GetValue( s );
            Console::Write( "\r\n {0} ({1}) =", s, rvk );
            for ( int i = 0; i < bytes->Length; i++ )
            {
               
               // Display each byte as two hexadecimal digits.
               Console::Write( " {0:X2}", bytes[ i ] );

            }
            Console::WriteLine();
            break;
         }
         default:
            Console::WriteLine( "\r\n {0} ({1}) = {2}", s, rvk, rk->GetValue( s ) );
            break;
      }
   }
}
/*

This code example produces the following output:
 QuadWordValue (QWord) = 42

 DWordValue (DWord) = 42

 MultipleStringValue (MultiString) =, "One", "Two", "Three"

 BinaryValue (Binary) = 0A 2B 2C 2D 0E FF

 StringValue (String) = The path is %PATH%

 ExpandedStringValue (ExpandString) = The path is C:\Program Files\Microsoft.NET\SDK\v2.0\Bin;
 [***The remainder of this output is omitted.***]

*/
using System;
using Microsoft.Win32;

public class Example
{
    public static void Main()
    {
        // Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample", false);
        RegistryKey rk = Registry.CurrentUser.CreateSubKey("RegistryValueKindExample");

        // Create name/value pairs.

        // This overload supports QWord (long) values.
        rk.SetValue("QuadWordValue", 42, RegistryValueKind.QWord);

        // The following SetValue calls have the same effect as using the
        // SetValue overload that does not specify RegistryValueKind.
        //
        rk.SetValue("DWordValue", 42, RegistryValueKind.DWord);
        rk.SetValue("MultipleStringValue", new string[] {"One", "Two", "Three"}, RegistryValueKind.MultiString);
        rk.SetValue("BinaryValue", new byte[] {10, 43, 44, 45, 14, 255}, RegistryValueKind.Binary);
        rk.SetValue("StringValue", "The path is %PATH%", RegistryValueKind.String);

        // This overload supports setting expandable string values. Compare
        // the output from this value with the previous string value.
        rk.SetValue("ExpandedStringValue", "The path is %PATH%", RegistryValueKind.ExpandString);

        // Display all name/value pairs stored in the test key, with each
        // registry data type in parentheses.
        //
        string[] valueNames = rk.GetValueNames();
        foreach (string s in valueNames)
        {
            RegistryValueKind rvk = rk.GetValueKind(s);
            switch (rvk)
            {
                case RegistryValueKind.MultiString :
                    string[] values = (string[]) rk.GetValue(s);
                    Console.Write("\r\n {0} ({1}) =", s, rvk);
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (i != 0) Console.Write(",");
                        Console.Write(" \"{0}\"", values[i]);
                    }
                    Console.WriteLine();
                    break;

                case RegistryValueKind.Binary :
                    byte[] bytes = (byte[]) rk.GetValue(s);
                    Console.Write("\r\n {0} ({1}) =", s, rvk);
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        // Display each byte as two hexadecimal digits.
                        Console.Write(" {0:X2}", bytes[i]);
                    }
                    Console.WriteLine();
                    break;

                default :
                    Console.WriteLine("\r\n {0} ({1}) = {2}", s, rvk, rk.GetValue(s));
                    break;
            }
        }
    }
}
/*

This code example produces the following output:
 QuadWordValue (QWord) = 42

 DWordValue (DWord) = 42

 MultipleStringValue (MultiString) =, "One", "Two", "Three"

 BinaryValue (Binary) = 0A 2B 2C 2D 0E FF

 StringValue (String) = The path is %PATH%

 ExpandedStringValue (ExpandString) = The path is C:\Program Files\Microsoft.NET\SDK\v2.0\Bin;
 [***The remainder of this output is omitted.***]

*/
Imports Microsoft.Win32

Public Class Example
    Public Shared Sub Main()
        ' Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample", False)
        Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("RegistryValueKindExample")
        
        ' Create name/value pairs.
        ' This overload supports QWord (long) values. 
        rk.SetValue("QuadWordValue", 42, RegistryValueKind.QWord)
        
        ' The following SetValue calls have the same effect as using the
        ' SetValue overload that does not specify RegistryValueKind.
        '
        rk.SetValue("DWordValue", 42, RegistryValueKind.DWord)
        rk.SetValue("MultipleStringValue", New String() {"One", "Two", "Three"}, RegistryValueKind.MultiString)
        rk.SetValue("BinaryValue", New Byte() {10, 43, 44, 45, 14, 255}, RegistryValueKind.Binary)
        rk.SetValue("StringValue", "The path is %PATH%", RegistryValueKind.String) 
        
        ' This overload supports setting expandable string values. Compare
        ' the output from this value with the previous string value.
        rk.SetValue("ExpandedStringValue", "The path is %PATH%", RegistryValueKind.ExpandString)
        
        
        ' Display all name/value pairs stored in the test key, with each
        ' registry data type in parentheses.
        '
        Dim valueNames As String() = rk.GetValueNames()
        Dim s As String
        For Each s In  valueNames
            Dim rvk As RegistryValueKind = rk.GetValueKind(s)
            Select Case rvk
                Case RegistryValueKind.MultiString
                    Dim values As String() = CType(rk.GetValue(s), String())
                    Console.Write(vbCrLf & " {0} ({1}) =", s, rvk)
                    For i As Integer = 0 To values.Length - 1
                        If i <> 0 Then Console.Write(",")
                        Console.Write(" ""{0}""", values(i))
                    Next i
                    Console.WriteLine()
                
                Case RegistryValueKind.Binary
                    Dim bytes As Byte() = CType(rk.GetValue(s), Byte())
                    Console.Write(vbCrLf & " {0} ({1}) =", s, rvk)
                    For i As Integer = 0 To bytes.Length - 1
                        ' Display each byte as two hexadecimal digits.
                        Console.Write(" {0:X2}", bytes(i))
                    Next i
                    Console.WriteLine()
                
                Case Else
                    Console.WriteLine(vbCrLf & " {0} ({1}) = {2}", s, rvk, rk.GetValue(s))
            End Select
        Next s
    End Sub
End Class

'
'This code example produces the following output (some output is omitted):
'
' QuadWordValue (QWord) = 42
'
' DWordValue (DWord) = 42
'
' MultipleStringValue (MultiString) = "One", "Two", "Three"
'
' BinaryValue (Binary) = 0A 2B 2C 2D 0E FF
'
' StringValue (String) = The path is %PATH%
'
' ExpandedStringValue (ExpandString) = The path is C:\Program Files\Microsoft.NET\SDK\v2.0\Bin;
' [***The remainder of this output is omitted.***]

설명

참고

레지스트리 키에는 이름과 연결되지 않은 값이 하나 있을 수 있습니다. 레지스트리 편집기에서 명명 되지 않은 값이 표시 되 면 "(기본값)" 문자열 이름 대신 표시 됩니다. 이 명명되지 않은 값을 검색하려면 에 또는 null 빈 문자열("")을 지정합니다 name.

메서드는 GetValue 확장 가능한 문자열 값()RegistryValueKind.ExpandString을 검색할 때 로컬 환경의 데이터를 사용하여 환경 문자열을 확장합니다. 원격 컴퓨터의 레지스트리에서 확장 가능한 문자열 값을 검색하려면 메서드 오버로드를 사용하여 GetValue(String, Object, RegistryValueOptions) 환경 문자열을 확장하지 않도록 지정합니다.

참고

환경 변수에 대한 확장 가능한 참조가 포함된 값이 확장 가능한 문자열()이 아닌 문자열(RegistryValueKind.StringRegistryValueKind.ExpandString) GetValue 로 저장된 경우 확장되지 않습니다. 메서드를 호출하여 검색된 후 이러한 문자열을 확장할 ExpandEnvironmentVariables 수 있습니다.

참고

키에서 PerformanceData 데이터를 검색하는 권장 방법은 메서드 대신 클래스를 PerformanceCounterRegistryKey.GetValue 사용하는 것입니다.

GetValue 는 형식 REG_NONE 또는 REG_LINK 값을 읽는 것을 지원하지 않습니다. 두 경우 모두 실제 값 대신 기본값(null)이 반환됩니다.

추가 정보

적용 대상

GetValue(String, Object)

Source:
RegistryKey.cs

지정된 이름과 연결된 값을 검색합니다. 이름이 없으면 사용자가 제공하는 기본값을 반환합니다.

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

매개 변수

name
String

검색할 값의 이름입니다. 이 문자열은 대/소문자를 구분하지 않습니다.

defaultValue
Object

name이 없는 경우에 반환할 값입니다.

반환

확장되지 않은 상태로 유지되는 포함 환경 변수가 있는 name과 연결된 값이거나, defaultValue이 없으면 name입니다.

예외

사용자가 레지스트리 키를 읽는 데 필요한 사용 권한이 없는 경우

지정된 값이 포함된 RegistryKey가 닫힌 경우. 닫힌 키는 액세스할 수 없습니다.

지정된 값이 포함된 RegistryKey가 삭제 표시된 경우

사용자에게 필요한 레지스트리 권한이 없는 경우

예제

다음 코드 예제에서는 값이 있는 테스트 키를 만들고 해당 값을 검색합니다. 그런 다음, 이 예제에서는 키에서 존재하지 않는 값을 검색하려고 합니다. 이 경우 메서드는 GetValue 지정된 기본값을 반환합니다.

using namespace System;
using namespace Microsoft::Win32;

public ref class RegGetDef
{
public:
    static void Main()
    {
        // Create a reference to a valid key.  In order for this code to
        // work, the indicated key must have been created previously.
        // The key name is not case-sensitive.
        RegistryKey^ rk = Registry::LocalMachine->OpenSubKey("Software\\myTestKey", false);
        // Get the value from the specified name/value pair in the key.
        String^ valueName = "myTestValue";

        Console::WriteLine("Retrieving registry value ...");
        Console::WriteLine();
        Object^ o = rk->GetValue(valueName);
        Console::WriteLine("Object Type = " + o->GetType()->FullName);
        Console::WriteLine();
        switch (rk->GetValueKind(valueName))
        {
            case RegistryValueKind::String:
            case RegistryValueKind::ExpandString:
                Console::WriteLine("Value = " + o);
                break;
            case RegistryValueKind::Binary:
                for each (Byte^ b in (array<Byte^>^)o)
                {
                    Console::Write("{0:x2} ", b);
                }
                Console::WriteLine();
                break;
            case RegistryValueKind::DWord:
                Console::WriteLine("Value = " + Convert::ToString((Int32^)o));
                break;
            case RegistryValueKind::QWord:
                Console::WriteLine("Value = " + Convert::ToString((Int64^)o));
                break;
            case RegistryValueKind::MultiString:
                for each (String^ s in (array<String^>^)o)
                {
                    Console::Write("[{0:s}], ", s);
                }
                Console::WriteLine();
                break;
            default:
                Console::WriteLine("Value = (Unknown)");
                break;
        }

        // Attempt to retrieve a value that does not exist; the specified
        // default value is returned.
        String^ def = (String^)rk->GetValue("notavalue", "The default to return");
        Console::WriteLine();
        Console::WriteLine(def);
        
        rk->Close();
    }
};

int main()
{
    RegGetDef::Main();
}
/*
Output:
Retrieving registry value ...

Object Type = System.String

Value = testData

The default to return
*/
using System;
using Microsoft.Win32;

class RegGetDef
{
    public static void Main()
    {
        // Create a reference to a valid key.  In order for this code to
        // work, the indicated key must have been created previously.
        // The key name is not case-sensitive.
        RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\myTestKey", false);
        // Get the value from the specified name/value pair in the key.

        string valueName = "myTestValue";

        Console.WriteLine("Retrieving registry value ...");
        Console.WriteLine();
        object o = rk.GetValue(valueName);
        Console.WriteLine("Object Type = " + o.GetType().FullName);
        Console.WriteLine();
        switch (rk.GetValueKind(valueName))
        {
            case RegistryValueKind.String:
            case RegistryValueKind.ExpandString:
                Console.WriteLine("Value = " + o);
                break;
            case RegistryValueKind.Binary:
                foreach (byte b in (byte[])o)
                {
                    Console.Write("{0:x2} ", b);
                }
                Console.WriteLine();
                break;
            case RegistryValueKind.DWord:
                Console.WriteLine("Value = " + Convert.ToString((int)o));
                break;
            case RegistryValueKind.QWord:
                Console.WriteLine("Value = " + Convert.ToString((Int64)o));
                break;
            case RegistryValueKind.MultiString:
                foreach (string s in (string[])o)
                {
                    Console.Write("[{0:s}], ", s);
                }
                Console.WriteLine();
                break;
            default:
                Console.WriteLine("Value = (Unknown)");
                break;
        }

        // Attempt to retrieve a value that does not exist; the specified
        // default value is returned.
        string def = (string)rk.GetValue("notavalue", "The default to return");
        Console.WriteLine();
        Console.WriteLine(def);

        rk.Close();
    }
}
/*
Output:
Retrieving registry value ...

Object Type = System.String

Value = testData

The default to return
*/
Imports Microsoft.Win32

Public Class RegGetDef
    Public Shared Sub Main()
        ' Create a reference to a valid key.  In order for this code to
        ' work, the indicated key must have been created previously.
        ' The key name is not case-sensitive.
        Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\myTestKey", false)

        ' Get the value from the specified name/value pair in the key.
        Dim valueName As String = "myTestValue"

        Console.WriteLine("Retrieving registry value ...")
        Console.WriteLine()
        Dim o As Object = rk.GetValue(valueName)
        Console.WriteLine("Object Type = " + o.GetType().FullName)
        Console.WriteLine()
        Select Case rk.GetValueKind(valueName)
            Case RegistryValueKind.String
            Case RegistryValueKind.ExpandString
                Console.WriteLine("Value = " + o)
            Case RegistryValueKind.Binary
                For Each b As Byte In CType(o,Byte())
                    Console.Write("{0:x2} ", b)
                Next b
                Console.WriteLine()
            Case RegistryValueKind.DWord
                Console.WriteLine("Value = " + Convert.ToString(CType(o,Int32)))
            Case RegistryValueKind.QWord
                Console.WriteLine("Value = " + Convert.ToString(CType(o,Int64)))
            Case RegistryValueKind.MultiString
                For Each s As String In CType(o,String())
                    Console.Write("[{0:s}], ", s)
                Next s
                Console.WriteLine()
            Case Else
                Console.WriteLine("Value = (Unknown)")
        End Select

        ' Attempt to retrieve a value that does not exist; the specified
        ' default value is returned.
        Dim Def As String = rk.GetValue("notavalue", "The default to return")
        Console.WriteLine()
        Console.WriteLine(def)
        
        rk.Close()
    End Sub
End Class
'
' Output:
' Retrieving registry value ...
'
' Object Type = System.String
'
' Value = testData
'
'The default to return

설명

이 오버로드를 GetValue 사용하여 이름이 아직 없는 경우(예: 애플리케이션이 처음 실행된 경우)를 처리합니다. 이 오버로드를 호출할 때마다 매개 변수를 defaultValue 사용하여 가 없으면 name 반환할 값을 지정합니다.

참고

레지스트리 키에는 이름과 연결되지 않은 값이 하나 있을 수 있습니다. 레지스트리 편집기에서 명명 되지 않은 값이 표시 되 면 "(기본값)" 문자열 이름 대신 표시 됩니다. 이 명명되지 않은 값을 검색하려면 에 또는 null 빈 문자열("")을 지정합니다 name.

메서드는 GetValue 확장 가능한 문자열 값()RegistryValueKind.ExpandString을 검색할 때 로컬 환경의 데이터를 사용하여 환경 문자열을 확장합니다. 원격 컴퓨터의 레지스트리에서 확장 가능한 문자열 값을 검색하려면 오버로드를 사용하여 GetValue 환경 문자열을 확장하지 않도록 지정합니다.

참고

환경 변수에 대한 확장 가능한 참조가 포함된 값이 확장 가능한 문자열()이 아닌 문자열(RegistryValueKind.StringRegistryValueKind.ExpandString)로 저장된 경우 메서드는 GetValue 확장되지 않습니다. 메서드를 호출하여 검색된 후 이러한 문자열을 확장할 ExpandEnvironmentVariables 수 있습니다.

참고

키에서 PerformanceData 데이터를 검색하는 권장 방법은 메서드 대신 클래스를 PerformanceCounterRegistryKey.GetValue 사용하는 것입니다.

GetValue 는 형식 REG_NONE 또는 REG_LINK 값을 읽는 것을 지원하지 않습니다. 두 경우 모두 실제 값 대신 기본값(null)이 반환됩니다.

추가 정보

적용 대상