RegistryHive Enumeration
Represents the possible values for a top-level node on a foreign machine.
Assembly: mscorlib (in mscorlib.dll)
| Member name | Description | |
|---|---|---|
| ClassesRoot | Represents the HKEY_CLASSES_ROOT base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. | |
| CurrentUser | Represents the HKEY_CURRENT_USER base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. | |
| LocalMachine | Represents the HKEY_LOCAL_MACHINE base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. | |
| Users | Represents the HKEY_USERS base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. | |
| PerformanceData | Represents the HKEY_PERFORMANCE_DATA base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. | |
| CurrentConfig | Represents the HKEY_CURRENT_CONFIG base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. | |
| DynData | Represents the HKEY_DYN_DATA base key on another computer. This value can be passed to the OpenRemoteBaseKey method, to open this node remotely. |
RegistryHive values are used by the OpenRemoteBaseKey method to represent the top-level node of a requested key on a foreign (remote) machine. The node that can be opened with the OpenRemoteBaseKey method must be one of these top-level RegistryKeys. Further access to the subkeys of the identified node is available using using methods in RegistryKey, so long as the the user has appropriate permission.
The following code example shows how to open a registry key on a remote computer and enumerate the values of the key. The remote computer must be running the remote registry service. Specify the name of the remote computer as a command-line argument when invoking the program.
using namespace System; using namespace System::IO; using namespace System::Security::Permissions; using namespace Microsoft::Win32; int main( int argc, char *argv[] ) { RegistryKey ^ environmentKey; // Check that an argument was specified when the // program was invoked. if ( argc == 1 ) { Console::WriteLine( "Error: The name of the remote computer " "must be specified as input on the command line." ); return -1; } try { // Open HKEY_CURRENT_USER\Environment on a remote computer. environmentKey = RegistryKey::OpenRemoteBaseKey( RegistryHive::CurrentUser, gcnew String(argv[ 1 ]) )->OpenSubKey( "Environment" ); } catch ( IOException^ e ) { Console::WriteLine( "{0}: {1}", e->GetType()->Name, e->Message ); return -1; } // Print the values. Console::WriteLine( "\nThere are {0} values for {1}.", environmentKey->ValueCount.ToString(), environmentKey->Name ); array<String^>^valueNames = environmentKey->GetValueNames(); for ( int i = 0; i < environmentKey->ValueCount; i++ ) { Console::WriteLine( "{0,-20}: {1}", valueNames[ i ], environmentKey->GetValue( valueNames[ i ] )->ToString() ); } // Close the registry key. environmentKey->Close(); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.