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 包含五個索引鍵:

硬體 描述電腦中的實體硬體、設備磁碟機使用該硬體的方式,以及對應與核心模式驅動程式與使用者模式程式碼連結的相關資料。 每次啟動系統時,都會重新建立此金鑰中的所有資料。 Description 子機碼描述實際的電腦硬體。 DeviceMap 子機碼包含特定驅動程式類別的特定格式其他資料。 ResourceMap 子機碼描述哪些設備磁碟機會宣告哪些硬體資源。 Windows NT 診斷程式 (Winmsdp.exe) 可以在容易閱讀的表單中報告其內容。

SAM 使用者和群組帳戶安全性資訊的目錄服務資料庫,以及 Windows 2000 Server (SAM 中的網域目錄服務資料庫,稱為目錄服務資料庫) 。

安全性包含本機安全性原則,例如特定使用者權限。 此金鑰僅供 Windows 2000 安全性子系統使用。

軟體 每部電腦軟體資料庫。 此金鑰包含有關安裝在本機電腦上的軟體資料,以及其他組態資料的各種專案。

系統控制系統啟動、裝置驅動程式載入、Windows 2000 服務和作業系統行為。

依照慣例,如果 類似資料存在於 和 底下 CurrentUserLocalMachine ,則資料 CurrentUser 會優先使用。 不過,此機碼中的值也可以擴充 (,而不是取代 Registry.LocalMachine 中的) 資料。 此外,某些專案 (例如設備磁碟機載入專案,) 在 Registry.LocalMachine 外部發生,則沒有意義。

適用於