CurrentConfig Field
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Registry.CurrentConfig Field

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.

Namespace: Microsoft.Win32
Assembly: mscorlib (in mscorlib.dll)

public static readonly RegistryKey CurrentConfig
public static final RegistryKey CurrentConfig
public static final var CurrentConfig : RegistryKey
Not applicable.

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.

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.

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

import System.*;
import Microsoft.Win32.*;

class Reg
{
    public static void main(String[] args)
    {
        // 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);
    } //main

    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.get_Name());
        Console.WriteLine("-----------------------------------------------");
        // Print the contents of the array to the console.
        String s = null;
        for (int iCtr = 0; iCtr < names.get_Length(); iCtr++) {
            s = names[iCtr];
            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;
            }
        }
    } //PrintKeys
} //Reg

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show:
© 2016 Microsoft