RegistryHive Enumeration

Definition

Stellt die möglichen Werte für einen Knoten auf oberster Ebene auf einem fremden Computer dar.Represents the possible values for a top-level node on a foreign machine.

public enum class RegistryHive
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum RegistryHive
type RegistryHive = 
Public Enum RegistryHive
Vererbung
RegistryHive
Attribute

Felder

ClassesRoot -2147483648

Stellt den Basisschlüssel HKEY_CLASSES_ROOT auf einem anderen Computer dar.Represents the HKEY_CLASSES_ROOT base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

CurrentConfig -2147483643

Stellt den Basisschlüssel HKEY_CURRENT_CONFIG auf einem anderen Computer dar.Represents the HKEY_CURRENT_CONFIG base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

CurrentUser -2147483647

Stellt den Basisschlüssel HKEY_CURRENT_USER auf einem anderen Computer dar.Represents the HKEY_CURRENT_USER base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

DynData -2147483642

Stellt den Basisschlüssel HKEY_DYN_DATA auf einem anderen Computer dar.Represents the HKEY_DYN_DATA base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

LocalMachine -2147483646

Stellt den Basisschlüssel HKEY_LOCAL_MACHINE auf einem anderen Computer dar.Represents the HKEY_LOCAL_MACHINE base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

PerformanceData -2147483644

Stellt den Basisschlüssel HKEY_PERFORMANCE_DATA auf einem anderen Computer dar.Represents the HKEY_PERFORMANCE_DATA base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

Users -2147483645

Stellt den Basisschlüssel HKEY_USERS auf einem anderen Computer dar.Represents the HKEY_USERS base key on another computer. Dieser Wert kann an die OpenRemoteBaseKey(RegistryHive, String)-Methode übergeben werden, um diesen Knoten remote zu öffnen.This value can be passed to the OpenRemoteBaseKey(RegistryHive, String) method, to open this node remotely.

Beispiele

Im folgenden Codebeispiel wird gezeigt, wie ein Registrierungsschlüssel auf einem Remote Computer geöffnet und die Werte des Schlüssels aufgelistet werden.The following code example shows how to open a registry key on a remote computer and enumerate the values of the key. Auf dem Remote Computer muss der Remote Registrierungsdienst ausgeführt werden.The remote computer must be running the remote registry service. Geben Sie den Namen des Remote Computers als Befehlszeilenargument an, wenn Sie das Programm aufrufen.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();
}

using System;
using System.IO;
using System.Security.Permissions;
using Microsoft.Win32;


class RemoteKey
{
    static void Main(string[] args)
    {
        RegistryKey environmentKey;
        string remoteName;

        // Check that an argument was specified when the 
        // program was invoked.
        if(args.Length == 0)
        {
            Console.WriteLine("Error: The name of the remote " +
                "computer must be specified when the program is " +
                "invoked.");
            return;
        }
        else
        {
            remoteName = args[0];
        }

        try
        {
            // Open HKEY_CURRENT_USER\Environment 
            // on a remote computer.
            environmentKey = RegistryKey.OpenRemoteBaseKey(
                RegistryHive.CurrentUser, remoteName).OpenSubKey(
                "Environment");
        }
        catch(IOException e)
        {
            Console.WriteLine("{0}: {1}", 
                e.GetType().Name, e.Message);
            return;
        }

        // Print the values.
        Console.WriteLine("\nThere are {0} values for {1}.", 
            environmentKey.ValueCount.ToString(), 
            environmentKey.Name);
        foreach(string valueName in environmentKey.GetValueNames())
        {
            Console.WriteLine("{0,-20}: {1}", valueName, 
                environmentKey.GetValue(valueName).ToString());
        }

        // Close the registry key.
        environmentKey.Close();
    }
}
Imports System.IO
Imports System.Security.Permissions
Imports Microsoft.Win32


Public Class RemoteKey

    Shared Sub Main(commandLineArgs As String())
    
        Dim environmentKey As RegistryKey

        ' Check that an argument was specified when the 
        ' program was invoked.
        If commandLineArgs.Length = 0 Then
            Console.WriteLine("Error: The name of the remote " & _
                "computer must be specified as input on the " & _
                "command line.")
            Return
        End If

        Try
            ' Open HKEY_CURRENT_USER\Environment on a remote computer.
            environmentKey = RegistryKey.OpenRemoteBaseKey( _
                RegistryHive.CurrentUser, _
                commandLineArgs(0)).OpenSubKey("Environment")
        Catch ex As IOException
            Console.WriteLine("{0}: {1}", _
                ex.GetType().Name, ex.Message)
            Return
        End Try

        ' Print the values.
        Console.WriteLine("\nThere are {0} values For {1}.", _
            environmentKey.ValueCount.ToString(), environmentKey.Name)

        For Each valueName As String In environmentKey.GetValueNames()
            Console.WriteLine("{0,-20}: {1}", valueName, _
                environmentKey.GetValue(valueName).ToString())
        Next

        ' Close the registry key.
        environmentKey.Close()
    
    End Sub
End Class

Hinweise

RegistryHiveWerte werden von der OpenRemoteBaseKey -Methode verwendet, um den Knoten der obersten Ebene eines angeforderten Schlüssels auf einem fremden (Remote-) Computer darzustellen.RegistryHive values are used by the OpenRemoteBaseKey method to represent the top-level node of a requested key on a foreign (remote) machine. Der Knoten, der mit der OpenRemoteBaseKey-Methode geöffnet werden kann, muss eine der obersten Ebenen RegistryKeyssein.The node that can be opened with the OpenRemoteBaseKey method must be one of these top-level RegistryKeys. Weitere Zugriffe auf die Unterschlüssel des identifizierten Knotens stehen mithilfe von Methoden in RegistryKeyzur Verfügung, solange der Benutzer über die entsprechende Berechtigung verfügt.Further access to the subkeys of the identified node is available using methods in RegistryKey, so long as the user has appropriate permission.

Gilt für:

Siehe auch