Share via


Registry.LocalMachine Campo

Definizione

Contiene i dati relativi alla configurazione del computer locale. Questo campo legge la chiave base HKEY_LOCAL_MACHINE del Registro di sistema di 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 

Valore del campo

Esempio

Nell'esempio seguente viene illustrato come recuperare le sottochiavi di questa chiave e stamparne i nomi sullo schermo. Usare il metodo per creare un'istanza OpenSubKey della determinata sottochiave di interesse. È quindi possibile usare altre operazioni in RegistryKey per modificare tale chiave.

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

Commenti

LocalMachine contiene cinque chiavi:

Hardware Descrive l'hardware fisico nel computer, il modo in cui i driver di dispositivo usano tale hardware e mapping e dati correlati che collegano i driver in modalità kernel con codice in modalità utente. Tutti i dati in questa chiave vengono ricreati ogni volta che viene avviato il sistema. La sottochiave Description descrive l'hardware del computer effettivo. La sottochiave DeviceMap contiene dati vari in formati specifici di classi di driver. La sottochiave ResourceMap descrive quali driver di dispositivo dichiarano quali risorse hardware. Il programma Di diagnostica Windows NT (Winmsdp.exe) può segnalarne il contenuto in un modulo di facile lettura.

SAM Il database dei servizi directory delle informazioni di sicurezza per gli account utente e di gruppo e per i domini in Windows 2000 Server (SAM è Gestione account di sicurezza, noto come database dei servizi directory).

La sicurezza contiene i criteri di sicurezza locali, ad esempio diritti utente specifici. Questa chiave viene usata solo dal sottosistema di sicurezza windows 2000.

Software Il database software per computer. Questa chiave contiene dati sul software installato nel computer locale, insieme a vari elementi di dati di configurazione vari.

Sistema Controlli di avvio del sistema, caricamento del driver del dispositivo, servizi Windows 2000 e comportamento del sistema operativo.

Per convenzione, se esistono dati simili in CurrentUser e in LocalMachine, i dati in CurrentUser hanno la precedenza. Tuttavia, i valori in questa chiave possono anche estendere (anziché sostituire) i dati in Registro.LocalMachine. Inoltre, alcuni elementi (ad esempio il caricamento dei driver di dispositivo) sono senza significato se si verificano all'esterno del Registro di sistema.LocalMachine.

Si applica a