RegistryKey.OpenRemoteBaseKey メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RegistryKey.OpenRemoteBaseKey メソッドの意味・解説 

RegistryKey.OpenRemoteBaseKey メソッド

リモート コンピュータ上にある要求されキーを表す新しい RegistryKey を開きます

名前空間: Microsoft.Win32
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function OpenRemoteBaseKey
 ( _
    hKey As RegistryHive, _
    machineName As String _
) As RegistryKey
Dim hKey As RegistryHive
Dim machineName As String
Dim returnValue As RegistryKey

returnValue = RegistryKey.OpenRemoteBaseKey(hKey, machineName)
public static RegistryKey OpenRemoteBaseKey
 (
    RegistryHive hKey,
    string machineName
)
public:
static RegistryKey^ OpenRemoteBaseKey (
    RegistryHive hKey, 
    String^ machineName
)
public static RegistryKey OpenRemoteBaseKey
 (
    RegistryHive hKey, 
    String machineName
)
public static function OpenRemoteBaseKey
 (
    hKey : RegistryHive, 
    machineName : String
) : RegistryKey

パラメータ

hKey

RegistryHive 列挙体の開く対象の HKEY。

machineName

リモート コンピュータ

戻り値
要求されRegistryKey

例外例外
例外種類条件

ArgumentException

hKey無効です。

IOException

machineName が見つかりません。

ArgumentNullException

machineNamenull 参照 (Visual Basic では Nothing) です。

SecurityException

ユーザーに、この操作実行するための十分なアクセス許可がありません。

UnauthorizedAccessException

ユーザーに、必要なレジストリ権限がありません。

解説解説
使用例使用例

リモート コンピュータレジストリ キー開き、そのキーの値を列挙する方法次のコード例示しますリモート コンピュータは、リモート レジストリ サービス実行している必要がありますプログラム呼び出すときにリモート コンピュータ名をコマンドライン引数として指定します

Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Security.Permissions
Imports Microsoft.Win32

<Assembly: RegistryPermissionAttribute( _
    SecurityAction.RequestMinimum, _
    Read := "HKEY_CURRENT_USER\Environment")>
<Assembly: SecurityPermissionAttribute( _
    SecurityAction.RequestMinimum, UnmanagedCode := True)>

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
using System;
using System.IO;
using System.Security.Permissions;
using Microsoft.Win32;

[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum,
    Read = @"HKEY_CURRENT_USER\Environment")]
[assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum,
    UnmanagedCode = true)]

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();
    }
}
using namespace System;
using namespace System::IO;
using namespace System::Security::Permissions;
using namespace Microsoft::Win32;

[assembly:RegistryPermissionAttribute(SecurityAction::RequestMinimum,
Read="HKEY_CURRENT_USER\\Environment")];
[assembly:SecurityPermissionAttribute(SecurityAction::RequestMinimum,
UnmanagedCode=true)];
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();
}

import System.*;
import System.IO.*;
import System.Security.Permissions.*;
import Microsoft.Win32.*;

/** @assembly RegistryPermissionAttribute(SecurityAction.RequestMinimum, 
    Read = "HKEY_CURRENT_USER\\Environment")
 */
/** @assembly SecurityPermissionAttribute(SecurityAction.RequestMinimum, 
    UnmanagedCode = true)
 */
class RemoteKey
{
    public static void main(String[]
 args)
    {
        RegistryKey environmentKey;
        String remoteName;
        // Check that an argument was specified when the 
        // program was invoked.
        if (args.get_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().get_Name(), 
                e.get_Message());
            return;
        }

        // Print the values.
        Console.WriteLine("\nThere are {0} values for {1}.",
 
            Convert.ToString(environmentKey.get_ValueCount()), 
            environmentKey.get_Name());
        for (int iCtr = 0; iCtr < environmentKey.GetValueNames().get_Length();
            iCtr++) {
            String valueName = (String)environmentKey.GetValueNames().
                get_Item(iCtr);
            Console.WriteLine("{0,-20}: {1}", valueName, 
                environmentKey.GetValue(valueName).ToString());
        }

        // Close the registry key.
        environmentKey.Close();
    } //main
} //RemoteKey
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
RegistryKey クラス
RegistryKey メンバ
Microsoft.Win32 名前空間
RegistryHive 列挙
OpenSubKey



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「RegistryKey.OpenRemoteBaseKey メソッド」の関連用語

RegistryKey.OpenRemoteBaseKey メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RegistryKey.OpenRemoteBaseKey メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS