Registry.LocalMachine Pole

Definicja

Zawiera dane konfiguracji dla komputera lokalnego. To pole odczytuje HKEY_LOCAL_MACHINE klucza podstawowego rejestru Windows.

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 

Wartość pola

Przykłady

W poniższym przykładzie pokazano, jak pobrać podklucze tego klucza i wyświetlić ich nazwy na ekranie. OpenSubKey Użyj metody , aby utworzyć wystąpienie określonego podklucza zainteresowania. Następnie możesz użyć innych operacji w programie, RegistryKey aby manipulować tym kluczem.

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

Uwagi

LocalMachine zawiera pięć kluczy:

Sprzęt opisuje sprzęt fizyczny na komputerze, sposób używania tego sprzętu przez sterowniki urządzeń oraz mapowania i powiązanych danych, które łączą sterowniki trybu jądra z kodem trybu użytkownika. Wszystkie dane w tym kluczu są tworzone ponownie przy każdym uruchomieniu systemu. Podklucz Opis opisuje rzeczywisty sprzęt komputera. Podklucz DeviceMap zawiera różne dane w formatach specyficznych dla określonych klas sterowników. Podklucz ResourceMap opisuje sterowniki urządzeń, które twierdzą, które zasoby sprzętowe. Program diagnostyczny nt Windows (Winmsdp.exe) może zgłosić jego zawartość w łatwym do odczytania formularzu.

SAM Baza danych zabezpieczeń usług katalogowych dla kont użytkowników i grup oraz domen w Windows 2000 Server (SAM jest Menedżerem kont zabezpieczeń, znanym jako baza danych usług katalogowych).

Zabezpieczenia zawiera lokalne zasady zabezpieczeń, takie jak określone prawa użytkownika. Ten klucz jest używany tylko przez podsystem zabezpieczeń Windows 2000.

Oprogramowanie baza danych oprogramowania dla komputerów. Ten klucz zawiera dane dotyczące oprogramowania zainstalowanego na komputerze lokalnym wraz z różnymi elementami różnych danych konfiguracji.

System kontroluje uruchamianie systemu, ładowanie sterowników urządzeń, Windows 2000 usług i zachowanie systemu operacyjnego.

Zgodnie z konwencją, jeśli podobne dane istnieją w obszarze CurrentUser i w obszarze LocalMachine, dane w CurrentUser programie mają pierwszeństwo. Jednak wartości w tym kluczu mogą również rozszerzać (zamiast zastępować) dane w registry.LocalMachine. Ponadto niektóre elementy (takie jak wpisy ładowania sterownika urządzenia) są bez znaczenia, jeśli występują poza registry.LocalMachine.

Dotyczy