Registry.LocalMachine Fält
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Innehåller konfigurationsdata för den lokala datorn. Det här fältet läser Windows registerbasnyckeln 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
Fältvärde
Exempel
I följande exempel visas hur du hämtar undernycklarna för den här nyckeln och skriver ut deras namn på skärmen. OpenSubKey Använd metoden för att skapa en instans av den specifika undernyckeln av intresse. Du kan sedan använda andra åtgärder i RegistryKey för att ändra nyckeln.
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
Kommentarer
LocalMachine innehåller fem nycklar:
Maskinvara Beskriver den fysiska maskinvaran på datorn, hur enhetsdrivrutiner använder maskinvaran samt mappningar och relaterade data som länkar drivrutiner i kernelläge med kod i användarläge. Alla data i den här nyckeln återskapas varje gång systemet startas. Undernyckeln Beskrivning beskriver den faktiska datormaskinvaran. DeviceMap-undernyckeln innehåller diverse data i format som är specifika för vissa klasser av drivrutiner. Undernyckeln ResourceMap beskriver vilka enhetsdrivrutiner som hävdar vilka maskinvaruresurser. Windows NT Diagnostics-programmet (Winmsdp.exe) kan rapportera om innehållet i ett lättläst formulär.
SAM Katalogtjänstdatabasen med säkerhetsinformation för användar- och gruppkonton och för domänerna i Windows 2000 Server (SAM är säkerhetskontohanteraren, känd som katalogtjänstdatabasen).
Säkerhet Innehåller den lokala säkerhetsprincipen, till exempel specifika användarrättigheter. Den här nyckeln används endast av säkerhetsundersystemet Windows 2000.
Programvara Programdatabasen per dator. Den här nyckeln innehåller data om programvara som är installerad på den lokala datorn, tillsammans med olika objekt med diverse konfigurationsdata.
System Controls systemstart, inläsning av enhetsdrivrutiner, Windows 2000-tjänster och operativsystemsbeteende.
Enligt konventionen, om liknande data finns under CurrentUser och under LocalMachine, har data i CurrentUser företräde. Värden i den här nyckeln kan dock också utöka (i stället för att ersätta) data i Registry.LocalMachine. Vissa objekt (till exempel inläsningsposter för enhetsdrivrutiner) är också meningslösa om de inträffar utanför Registry.LocalMachine.