Registry.CurrentConfig 字段

定义

包含有关非用户特定的硬件的配置信息。Contains configuration information pertaining to the hardware that is not specific to the user. 该字段读取 Windows 注册表基项 HKEY_CURRENT_CONFIG。This field reads the Windows registry base key HKEY_CURRENT_CONFIG.

public: static initonly Microsoft::Win32::RegistryKey ^ CurrentConfig;
public static readonly Microsoft.Win32.RegistryKey CurrentConfig;
 staticval mutable CurrentConfig : Microsoft.Win32.RegistryKey
Public Shared ReadOnly CurrentConfig 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_CURRENT_CONFIG
   // key in the registry of this machine.
   RegistryKey ^ rk = Registry::CurrentConfig;
   
   // 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_CURRENT_CONFIG
        // key in the registry of this machine.
        RegistryKey rk = Registry.CurrentConfig;

        // 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_CURRENT_CONFIG
        ' key in the registry of this machine.
        Dim rk As RegistryKey = Registry.CurrentConfig
        
        ' 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

注解

此成员映射到中的子项 LocalMachineThis member is mapped to a subkey within LocalMachine.

使用此成员的一个示例是应用程序,该应用程序根据系统是否连接到网络,为其数据存储不同的服务器名称。An example of using this member is an application that stores a different server name for its data depending on whether the system is attached to a network.

适用于