RegistryKey.OpenRemoteBaseKey 메서드

정의

새 T:Microsoft 엽니다. 지정된 레지스트리 보기 옵션을 사용하여 원격 컴퓨터에서 요청된 키를 나타내는 Win32.RegistryKey입니다.

오버로드

Name Description
OpenRemoteBaseKey(RegistryHive, String)

원격 컴퓨터에서 요청된 키를 나타내는 새 RegistryKey 키를 엽니다.

OpenRemoteBaseKey(RegistryHive, String, RegistryView)

지정된 보기를 사용하여 원격 머신에서 요청된 키를 나타내는 새 레지스트리 키를 엽니다.

OpenRemoteBaseKey(RegistryHive, String)

원격 컴퓨터에서 요청된 키를 나타내는 새 RegistryKey 키를 엽니다.

public:
 static Microsoft::Win32::RegistryKey ^ OpenRemoteBaseKey(Microsoft::Win32::RegistryHive hKey, System::String ^ machineName);
public static Microsoft.Win32.RegistryKey OpenRemoteBaseKey(Microsoft.Win32.RegistryHive hKey, string machineName);
static member OpenRemoteBaseKey : Microsoft.Win32.RegistryHive * string -> Microsoft.Win32.RegistryKey
Public Shared Function OpenRemoteBaseKey (hKey As RegistryHive, machineName As String) As RegistryKey

매개 변수

hKey
RegistryHive

열거형에서 RegistryHive 열 HKEY입니다.

machineName
String

원격 컴퓨터입니다.

반품

요청된 레지스트리 키입니다.

예외

hKey 가 잘못되었습니다.

machineName 찾을 수 없습니다.

machineNamenull입니다.

사용자에게 이 작업을 수행할 수 있는 적절한 권한이 없습니다.

사용자에게 필요한 레지스트리 권한이 없습니다.

예제

다음 코드 예제에서는 원격 컴퓨터에서 레지스트리 키를 열고 키의 값을 열거하는 방법을 보여 있습니다. 원격 컴퓨터가 원격 레지스트리 서비스를 실행해야 합니다. 프로그램을 호출할 때 원격 컴퓨터의 이름을 명령줄 인수로 지정합니다.

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

설명

로컬 컴퓨터 레지스트리(있는 경우 machineName )가 열립니다 String.Empty. 요청된 키는 원격 컴퓨터의 루트 키여야 하며 적절한 RegistryHive 값으로 식별됩니다.

키를 원격으로 열려면 서버와 클라이언트 컴퓨터가 모두 원격 레지스트리 서비스를 실행하고 원격 관리를 사용하도록 설정해야 합니다.

추가 정보

적용 대상

OpenRemoteBaseKey(RegistryHive, String, RegistryView)

지정된 보기를 사용하여 원격 머신에서 요청된 키를 나타내는 새 레지스트리 키를 엽니다.

public:
 static Microsoft::Win32::RegistryKey ^ OpenRemoteBaseKey(Microsoft::Win32::RegistryHive hKey, System::String ^ machineName, Microsoft::Win32::RegistryView view);
[System.Runtime.InteropServices.ComVisible(false)]
public static Microsoft.Win32.RegistryKey OpenRemoteBaseKey(Microsoft.Win32.RegistryHive hKey, string machineName, Microsoft.Win32.RegistryView view);
[<System.Runtime.InteropServices.ComVisible(false)>]
static member OpenRemoteBaseKey : Microsoft.Win32.RegistryHive * string * Microsoft.Win32.RegistryView -> Microsoft.Win32.RegistryKey
Public Shared Function OpenRemoteBaseKey (hKey As RegistryHive, machineName As String, view As RegistryView) As RegistryKey

매개 변수

hKey
RegistryHive

열거형에서 열 HKEY RegistryHive 입니다.

machineName
String

원격 컴퓨터입니다.

view
RegistryView

사용할 레지스트리 뷰입니다.

반품

요청된 레지스트리 키입니다.

특성

예외

hKey 또는 view 잘못되었습니다.

machineName 찾을 수 없습니다.

machineNamenull입니다.

사용자에게 필요한 레지스트리 권한이 없습니다.

사용자에게 이 작업을 수행하는 데 필요한 권한이 없습니다.

설명

로컬 컴퓨터 레지스트리(있는 경우 machineName )가 열립니다 String.Empty. 요청된 키는 원격 컴퓨터의 루트 키여야 하며 적절한 RegistryHive 값으로 식별됩니다.

키를 원격으로 열려면 서버와 클라이언트 컴퓨터가 모두 원격 레지스트리 서비스를 실행하고 원격 관리를 사용하도록 설정해야 합니다.

64비트 버전의 Windows 레지스트리 부분은 32비트 및 64비트 애플리케이션에 대해 별도로 저장됩니다. 32비트 애플리케이션에 대한 32비트 보기와 64비트 애플리케이션에 대한 64비트 보기가 있습니다. Registry64 원격 컴퓨터가 32비트 운영 체제를 실행 중인 경우 view 반환된 키는 보기를 사용합니다Registry32.

적용 대상