Registry.LocalMachine 字段

定义

包含本地计算机的配置数据。Contains the configuration data for the local machine. 该字段读取 Windows 注册表基项 HKEY_LOCAL_MACHINE。This field reads the Windows registry base key 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 

字段值

RegistryKey

示例

下面的示例演示如何检索此项的子项,并将其名称打印到屏幕。The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. 使用 OpenSubKey 方法可以创建感兴趣的特定子项的实例。Use the OpenSubKey method to create an instance of the particular subkey of interest. 然后,可以使用中的其他操作 RegistryKey 来操作该密钥。You can then use other operations in RegistryKey to manipulate that key.

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 包含五个密钥:LocalMachine contains five keys:

硬件Hardware
描述计算机的物理硬件、设备驱动程序使用该硬件的方式,以及将内核模式驱动程序与用户模式代码链接的映射和相关数据。Describes the physical hardware in the computer, the way device drivers use that hardware, and mappings and related data that link kernel-mode drivers with user-mode code. 每次系统启动时,都将重新创建此密钥中的所有数据。All data in this key is recreated each time the system is started. 说明子项描述了实际的计算机硬件。The Description subkey describes the actual computer hardware. DeviceMap 子项包含特定于特定类驱动程序的格式的杂项数据。The DeviceMap subkey contains miscellaneous data in formats specific to particular classes of drivers. Windows.applicationmodel.resources.core.resourcemap 子项说明哪些设备驱动程序声明了哪些硬件资源。The ResourceMap subkey describes which device drivers claim which hardware resources. Windows NT 诊断程序 ( # A0) 可以通过易于阅读的形式报告其内容。The Windows NT Diagnostics program (Winmsdp.exe) can report on its contents in an easy-to-read form.

SAMSAM
用户帐户和组帐户的安全信息的目录服务数据库以及 Windows 2000 Server (SAM 中的域的目录服务数据库是安全帐户管理器(称为目录服务数据库) )。The directory services database of security information for user and group accounts, and for the domains in Windows 2000 Server (SAM is the Security Account Manager, known as the directory services database).

安全性Security
包含本地安全策略,如特定的用户权限。Contains the local security policy, such as specific user rights. 此密钥仅由 Windows 2000 安全子系统使用。This key is used only by the Windows 2000 security subsystem.

软件Software
每台计算机的软件数据库。The per-computer software database. 此密钥包含与本地计算机上安装的软件有关的数据,以及各种不同的配置数据。This key contains data about software installed on the local computer, along with various items of miscellaneous configuration data.

系统System
控制系统启动、设备驱动程序加载、Windows 2000 服务和操作系统行为。Controls system startup, device driver loading, Windows 2000 services, and operating system behavior.

按照约定,如果在 CurrentUser 和下存在类似数据 LocalMachine ,则中的数据 CurrentUser 优先。By convention, if similar data exists under CurrentUser and under LocalMachine, the data in CurrentUser takes precedence. 但是,此键中的值还可以扩展 (而不是替换 Registry 中) 的数据。However, values in this key can also extend (rather than replace) data in Registry.LocalMachine. 此外,某些项 (如设备驱动程序加载项) 在 Registry 之外发生时无意义。Also, some items (such as device driver loading entries) are meaningless if they occur outside of Registry.LocalMachine.

适用于