RegistryKey.GetValue メソッド

定義

指定した名前に関連付けられている値を取得します。

オーバーロード

名前 説明
GetValue(String, Object, RegistryValueOptions)

指定した名前と取得オプションに関連付けられている値を取得します。 名前が見つからない場合は、指定した既定値を返します。

GetValue(String)

指定した名前に関連付けられている値を取得します。 名前と値のペアがレジストリに存在しない場合は、 null を返します。

GetValue(String, Object)

指定した名前に関連付けられている値を取得します。 名前が見つからない場合は、指定した既定値を返します。

GetValue(String, Object, RegistryValueOptions)

ソース:
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

取得した値のオプションの処理を指定する列挙値の 1 つ。

返品

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

注釈

このオーバーロードを使用して、取得した値の特別な処理を指定します。 たとえば、RegistryValueOptions.DoNotExpandEnvironmentNames型のレジストリ値を取得するときにRegistryValueKind.ExpandStringを指定して、埋め込み環境変数を展開せずに文字列を取得できます。

defaultValue パラメーターを使用して、nameが存在しない場合に返す値を指定します。

Note

レジストリ キーには、どの名前にも関連付けられていない値を 1 つ持つことができます。 この名前のない値がレジストリ エディターに表示されると、名前の代わりに文字列 "(Default)" が表示されます。 この名前のない値を取得するには、 null または空の文字列 ("") を nameに指定します。

GetValue では、REG_NONE型またはREG_LINK型の値の読み取りはサポートされていません。 どちらの場合も、実際の値ではなく既定値 (null) が返されます。

こちらもご覧ください

適用対象

GetValue(String)

ソース:
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に関連付けられている値。nullが見つからない場合はname

例外

ユーザーには、レジストリ キーから読み取るために必要なアクセス許可がありません。

指定した値を含む 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.***]

注釈

Note

レジストリ キーには、どの名前にも関連付けられていない値を 1 つ持つことができます。 この名前のない値がレジストリ エディターに表示されると、名前の代わりに文字列 "(Default)" が表示されます。 この名前のない値を取得するには、 null または空の文字列 ("") を nameに指定します。

GetValue メソッドは、展開可能な文字列値 (RegistryValueKind.ExpandString) を取得するときに、ローカル環境のデータを使用して環境文字列を展開します。 リモート コンピューター上のレジストリから展開可能な文字列値を取得するには、 GetValue(String, Object, RegistryValueOptions) メソッドのオーバーロードを使用して、環境文字列を展開しないように指定します。

Note

環境変数への展開可能な参照を含む値が、展開可能な文字列 (RegistryValueKind.String) ではなく、文字列 (RegistryValueKind.ExpandString) として格納されている場合、GetValueは展開されません。 このような文字列は、 ExpandEnvironmentVariables メソッドを呼び出して取得した後で展開できます。

Note

PerformanceData キーからデータを取得するには、PerformanceCounter メソッドではなく RegistryKey.GetValue クラスを使用することをお勧めします。

GetValue では、REG_NONE型またはREG_LINK型の値の読み取りはサポートされていません。 どちらの場合も、実際の値ではなく既定値 (null) が返されます。

こちらもご覧ください

適用対象

GetValue(String, Object)

ソース:
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 が存在しない場合に返す値を指定します。

Note

レジストリ キーには、どの名前にも関連付けられていない値を 1 つ持つことができます。 この名前のない値がレジストリ エディターに表示されると、名前の代わりに文字列 "(Default)" が表示されます。 この名前のない値を取得するには、 null または空の文字列 ("") を nameに指定します。

GetValue メソッドは、展開可能な文字列値 (RegistryValueKind.ExpandString) を取得するときに、ローカル環境のデータを使用して環境文字列を展開します。 リモート コンピューター上のレジストリから展開可能な文字列値を取得するには、 GetValue オーバーロードを使用して、環境文字列を展開しないように指定します。

Note

環境変数への展開可能な参照を含む値が、展開可能な文字列 (RegistryValueKind.String) ではなく、文字列 (RegistryValueKind.ExpandString) として格納されている場合、GetValue メソッドはそれを展開しません。 このような文字列は、 ExpandEnvironmentVariables メソッドを呼び出して取得した後で展開できます。

Note

PerformanceData キーからデータを取得するには、PerformanceCounter メソッドではなく RegistryKey.GetValue クラスを使用することをお勧めします。

GetValue では、REG_NONE型またはREG_LINK型の値の読み取りはサポートされていません。 どちらの場合も、実際の値ではなく既定値 (null) が返されます。

こちらもご覧ください

適用対象