Registry.LocalMachine フィールド

定義

ローカル コンピューターの構成データを格納します。 このフィールドは、Windows レジストリの基本キー HKEY_LOCAL_MACHINEを読み取ります。

public: static initonly Microsoft::Win32::RegistryKey ^ LocalMachine;
public static readonly Microsoft.Win32.RegistryKey LocalMachine;
 staticval mutable LocalMachine : Microsoft.Win32.RegistryKey
Public Shared ReadOnly LocalMachine As RegistryKey 

フィールド値

次の例では、このキーのサブキーを取得し、その名前を画面に出力する方法を示します。 OpenSubKey メソッドを使用して、対象の特定のサブキーのインスタンスを作成します。 その後、 RegistryKey で他の操作を使用して、そのキーを操作できます。

using namespace System;
using namespace Microsoft::Win32;
void PrintKeys( RegistryKey ^ rkey )
{
   
   // Retrieve all the subkeys for the specified key.
   array<String^>^names = rkey->GetSubKeyNames();
   int icount = 0;
   Console::WriteLine( "Subkeys of {0}", rkey->Name );
   Console::WriteLine( "-----------------------------------------------" );
   
   // Print the contents of the array to the console.
   System::Collections::IEnumerator^ enum0 = names->GetEnumerator();
   while ( enum0->MoveNext() )
   {
      String^ s = safe_cast<String^>(enum0->Current);
      Console::WriteLine( s );
      
      // The following code puts a limit on the number
      // of keys displayed.  Comment it out to print the
      // complete list.
      icount++;
      if ( icount >= 10 )
            break;
   }
}

int main()
{
   
   // Create a RegistryKey, which will access the HKEY_LOCAL_MACHINE
   // key in the registry of this machine.
   RegistryKey ^ rk = Registry::LocalMachine;
   
   // Print out the keys.
   PrintKeys( rk );
}
using System;
using Microsoft.Win32;

class Reg {
    public static void Main() {

        // Create a RegistryKey, which will access the HKEY_LOCAL_MACHINE
        // key in the registry of this machine.
         RegistryKey rk = Registry.LocalMachine;

        // Print out the keys.
        PrintKeys(rk);
    }

    static void PrintKeys(RegistryKey rkey) {

        // Retrieve all the subkeys for the specified key.
        string [] names = rkey.GetSubKeyNames();

        int icount = 0;

        Console.WriteLine("Subkeys of " + rkey.Name);
        Console.WriteLine("-----------------------------------------------");

        // Print the contents of the array to the console.
        foreach (string s in names) {
            Console.WriteLine(s);

            // The following code puts a limit on the number
            // of keys displayed.  Comment it out to print the
            // complete list.
            icount++;
            if (icount >= 10)
                break;
        }
    }
}
Imports Microsoft.Win32

Class Reg
    
    Public Shared Sub Main()
        
        ' Create a RegistryKey, which will access the HKEY_LOCAL_MACHINE
        ' key in the registry of this machine.
        Dim rk As RegistryKey = Registry.LocalMachine
        
        ' Print out the keys.
        PrintKeys(rk)
    End Sub    
    
    Shared Sub PrintKeys(rkey As RegistryKey)
        
        ' Retrieve all the subkeys for the specified key.
        Dim names As String() = rkey.GetSubKeyNames()
        
        Dim icount As Integer = 0
        
        Console.WriteLine("Subkeys of " & rkey.Name)
        Console.WriteLine("-----------------------------------------------")
        
        ' Print the contents of the array to the console.
        Dim s As String
        For Each s In  names
            Console.WriteLine(s)
            
            ' The following code puts a limit on the number
            ' of keys displayed.  Comment it out to print the
            ' complete list.
            icount += 1            
            If icount >= 10 Then
                Exit For
            End If
        Next s
    End Sub
End Class

注釈

LocalMachine には、次の 5 つのキーが含まれています。

ハードウェア コンピューター内の物理ハードウェア、デバイス ドライバーがそのハードウェアを使用する方法、およびカーネル モード ドライバーとユーザー モード コードをリンクするマッピングと関連データについて説明します。 このキー内のすべてのデータは、システムが開始されるたびに再作成されます。 Description サブキーは、実際のコンピューター ハードウェアを記述します。 DeviceMap サブキーには、ドライバーの特定のクラスに固有の形式のその他のデータが含まれています。 ResourceMap サブキーは、どのデバイス ドライバーがどのハードウェア リソースを要求するかを示します。 Windows NT 診断プログラム (Winmsdp.exe) は、その内容を読みやすい形式で報告できます。

SAM ユーザー アカウントとグループ アカウント、および Windows 2000 Server のドメインのセキュリティ情報のディレクトリ サービス データベース (SAM は、ディレクトリ サービス データベースと呼ばれるセキュリティ アカウント マネージャーです)。

セキュリティ 特定のユーザー権限など、ローカル セキュリティ ポリシーが含まれます。 このキーは、Windows 2000 セキュリティ サブシステムでのみ使用されます。

ソフトウェア コンピューター単位のソフトウェア データベース。 このキーには、ローカル コンピューターにインストールされているソフトウェアに関するデータと、その他の構成データのさまざまな項目が含まれます。

システム コントロール システムの起動、デバイス ドライバーの読み込み、Windows 2000 サービス、オペレーティング システムの動作。

慣例により、同様のデータが CurrentUserLocalMachineの下に存在する場合、 CurrentUser 内のデータが優先されます。 ただし、このキーの値は Registry.LocalMachine のデータを (置き換えではなく) 拡張することもできます。 また、一部の項目 (デバイス ドライバーの読み込みエントリなど) は、Registry.LocalMachine の外部で発生した場合は意味がありません。

適用対象