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 initonly RegistryKey^ CurrentConfig

Field Value

Type: Microsoft.Win32::RegistryKey^

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

.NET Framework
Available since 1.1
Return to top
Show: