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 

字段值

示例

下面的示例演示如何检索此项的子项,并将其名称在屏幕上的打印。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. ResourceMap 子项描述的设备驱动程序声明的硬件资源。The ResourceMap subkey describes which device drivers claim which hardware resources. Windows NT 诊断程序 (Winmsdp.exe) 可以报告其内容的易读的窗体中。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.LocalMachine 中的数据。However, values in this key can also extend (rather than replace) data in Registry.LocalMachine. 此外,某些项 (如设备驱动程序加载项) 是外部 Registry.LocalMachine 它们出现的情况下没有意义。Also, some items (such as device driver loading entries) are meaningless if they occur outside of Registry.LocalMachine.

适用于