RegistryKey.OpenRemoteBaseKey 메서드

정의

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

오버로드

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 가 없는 경우

machineName이(가) null인 경우

이 작업을 수행하는 데 필요한 해당 권한이 사용자에게 없는 경우

사용자에게 필요한 레지스트리 권한이 없는 경우

예제

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

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

설명

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

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

추가 정보

적용 대상

OpenRemoteBaseKey(RegistryHive, String, RegistryView)

지정된 뷰를 사용하여 원격 컴퓨터의 요청된 키를 나타내는 새 레지스트리 키를 엽니다.

public:
 static Microsoft::Win32::RegistryKey ^ OpenRemoteBaseKey(Microsoft::Win32::RegistryHive hKey, System::String ^ machineName, Microsoft::Win32::RegistryView view);
public static Microsoft.Win32.RegistryKey OpenRemoteBaseKey (Microsoft.Win32.RegistryHive hKey, 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);
static member OpenRemoteBaseKey : Microsoft.Win32.RegistryHive * string * Microsoft.Win32.RegistryView -> Microsoft.Win32.RegistryKey
[<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

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

machineName
String

원격 컴퓨터입니다.

view
RegistryView

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

반환

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

특성

예외

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

machineName 가 없는 경우

machineName이(가) null인 경우

사용자에게 필요한 레지스트리 권한이 없는 경우

이 작업을 수행하는 데 필요한 권한이 사용자에게 없는 경우

설명

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

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

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

적용 대상