Op Englesch liesen Editéieren

Deelen iwwer


Registry.CurrentConfig Field

Definition

Contains configuration information pertaining to the hardware that is not specific to the user. This field reads the Windows registry base key HKEY_CURRENT_CONFIG.

C#
public static readonly Microsoft.Win32.RegistryKey CurrentConfig;

Field Value

Examples

The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. Use the OpenSubKey method to create an instance of the particular subkey of interest. You can then use other operations in RegistryKey to manipulate that key.

C#
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;
        }
    }
}

Remarks

This 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.

Applies to

Produkt Versiounen
.NET Core 1.0, Core 1.1, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5