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

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

RegistryKey.GetValueKind メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定した前に関連付けられた値のレジストリ データ型取得します

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

<ComVisibleAttribute(False)> _
Public Function GetValueKind ( _
    name As String _
) As RegistryValueKind
Dim instance As RegistryKey
Dim name As String
Dim returnValue As RegistryValueKind

returnValue = instance.GetValueKind(name)
[ComVisibleAttribute(false)] 
public RegistryValueKind GetValueKind (
    string name
)
[ComVisibleAttribute(false)] 
public:
RegistryValueKind GetValueKind (
    String^ name
)
/** @attribute ComVisibleAttribute(false) */ 
public RegistryValueKind GetValueKind (
    String name
)
ComVisibleAttribute(false) 
public function GetValueKind (
    name : String
) : RegistryValueKind

パラメータ

name

レジストリ データ型取得する値の名前。

戻り値
name関連付けられた値のレジストリ データ型を表す RegistryValueKind 値。

例外例外
例外種類条件

SecurityException

ユーザーに、レジストリ キーからの読み取り必要なアクセス許可がありません。

ObjectDisposedException

指定された値を格納している RegistryKey が閉じてます。閉じられキーにはアクセスできません。

IOException

指定された値を格納しているサブキーが存在しません。

または

name指定された名前/値ペアが存在しません。

この例外は、Windows 95Windows 98、および Windows Millennium Edition ではスローされません。

UnauthorizedAccessException

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

解説解説
使用例使用例

テスト キー作成し、このキーさまざまなデータ型の値を追加するコード例次に示します。さらに、この例では GetValueKind メソッド使用して対応するレジストリ データ型取得し、名前/値ペア読み取ってコンソール表示します

Imports System
Imports Microsoft.Win32
Imports Microsoft.VisualBasic

Public Class Example
    Public Shared Sub Main()
        ' Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample",
 False)
        Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("RegistryValueKindExample")
        
        ' Create name/value pairs.
        ' This overload supports QWord (long) values. 
        rk.SetValue("QuadWordValue", 42, RegistryValueKind.QWord)
        
        ' The following SetValue calls have the same effect as using
 the
        ' SetValue overload that does not specify RegistryValueKind.
        '
        rk.SetValue("DWordValue", 42, RegistryValueKind.DWord)
        rk.SetValue("MultipleStringValue", New
 String() {"One", "Two",
 "Three"}, RegistryValueKind.MultiString)
        rk.SetValue("BinaryValue", New
 Byte() {10, 43, 44, 45, 14, 255}, RegistryValueKind.Binary)
        rk.SetValue("StringValue", "The
 path is %PATH%", RegistryValueKind.String) 
        
        ' This overload supports setting expandable string values. Compare
        ' the output from this value with the previous string value.
        rk.SetValue("ExpandedStringValue", "The
 path is %PATH%", RegistryValueKind.ExpandString)
        
        
        ' Display all name/value pairs stored in the test key, with
 each
        ' registry data type in parentheses.
        '
        Dim valueNames As String()
 = rk.GetValueNames()
        Dim s As String
        For Each s In  valueNames
            Dim rvk As RegistryValueKind =
 rk.GetValueKind(s)
            Select Case rvk
                Case RegistryValueKind.MultiString
                    Dim values As String()
 = CType(rk.GetValue(s), String())
                    Console.Write(vbCrLf + " {0} ({1}) = ""{2}""",
 s, rvk, values(0))
                    Dim i As Integer
                    For i = 1 To values.Length
 - 1
                        Console.Write(", ""{0}""",
 values(i))
                    Next i
                    Console.WriteLine()
                
                Case RegistryValueKind.Binary
                    Dim bytes As Byte()
 = CType(rk.GetValue(s), Byte())
                    Console.Write(vbCrLf + " {0} ({1}) = {2:X2}",
 s, rvk, bytes(0))
                    Dim i As Integer
                    For i = 1 To bytes.Length
 - 1
                        ' Display each byte as two hexadecimal digits.
                        Console.Write(" {0:X2}", bytes(i))
                    Next i
                    Console.WriteLine()
                
                Case Else
                    Console.WriteLine(vbCrLf + " {0} ({1}) = {2}",
 s, rvk, rk.GetValue(s))
            End Select
        Next s
    End Sub 'Main
End Class 'Example
using System;
using Microsoft.Win32;

public class Example
{
    public static void Main()
    {
        // Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample", false);
        RegistryKey rk = Registry.CurrentUser.CreateSubKey("RegistryValueKindExample");

        // Create name/value pairs.

        // This overload supports QWord (long) values. 
        rk.SetValue("QuadWordValue", 42, RegistryValueKind.QWord);

        // The following SetValue calls have the same effect as using
 the
        // SetValue overload that does not specify RegistryValueKind.
        //
        rk.SetValue("DWordValue", 42, RegistryValueKind.DWord);
        rk.SetValue("MultipleStringValue", new string[]
 {"One", "Two", "Three"}, RegistryValueKind.MultiString);
        rk.SetValue("BinaryValue", new byte[] {10, 43,
 44, 45, 14, 255}, RegistryValueKind.Binary);
        rk.SetValue("StringValue", "The path is %PATH%", RegistryValueKind.String);

        // This overload supports setting expandable string values.
 Compare
        // the output from this value with the previous string value.
        rk.SetValue("ExpandedStringValue", "The path is %PATH%"
,
 RegistryValueKind.ExpandString);


        // Display all name/value pairs stored in the test key, with
 each
        // registry data type in parentheses.
        //
        string[] valueNames = rk.GetValueNames();
        foreach (string s in
 valueNames)
        {
            RegistryValueKind rvk = rk.GetValueKind(s);
            switch (rvk)
            {
                case RegistryValueKind.MultiString :
                    string[] values = (string[])
 rk.GetValue(s);
                    Console.Write("\r\n {0} ({1}) = \"{2}\"",
 s, rvk, values[0]);
                    for (int i = 1; i <
 values.Length; i++)
                    {
                        Console.Write(", \"{0}\"", values[i]);
                    }
                    Console.WriteLine();
                    break;
                
                case RegistryValueKind.Binary :
                    byte[] bytes = (byte[]) rk.GetValue(s);
                    Console.Write("\r\n {0} ({1}) = {2:X2}", s, rvk, bytes[0]);
                    for (int i = 1; i <
 bytes.Length; i++)
                    {
                        // Display each byte as two hexadecimal digits.
                        Console.Write(" {0:X2}", bytes[i]);
                    }
                    Console.WriteLine();
                    break;
                
                default :
                    Console.WriteLine("\r\n {0} ({1}) = {2}", s, rvk, rk.GetValue(s));
                    break;
            }
        }
    }
}
using namespace System;
using namespace Microsoft::Win32;
int main()
{
   
   // Delete and recreate the test key.
   Registry::CurrentUser->DeleteSubKey( "RegistryValueKindExample",
 false );
   RegistryKey ^ rk = Registry::CurrentUser->CreateSubKey( "RegistryValueKindExample"
 );
   
   // Create name/value pairs.
   // This overload supports QWord (long) values. 
   rk->SetValue( "QuadWordValue", 42, RegistryValueKind::QWord );
   
   // The following SetValue calls have the same effect as using the
   // SetValue overload that does not specify RegistryValueKind.
   //
   rk->SetValue( "DWordValue", 42, RegistryValueKind::DWord );
   rk->SetValue( "MultipleStringValue", gcnew array<String^>{
      "One","Two","Three"
   }, RegistryValueKind::MultiString );
   rk->SetValue( "BinaryValue", gcnew array<Byte>{
      10,43,44,45,14,255
   }, RegistryValueKind::Binary );
   rk->SetValue( "StringValue", "The path is %PATH%", RegistryValueKind::String
 );
   
   // This overload supports setting expandable string values. Compare
   // the output from this value with the previous string value.
   rk->SetValue( "ExpandedStringValue", "The path is %PATH%",
 RegistryValueKind::ExpandString );
   
   // Display all the name/value pairs stored in the test key, with
 the
   // registry data type in parentheses.
   //
   array<String^>^valueNames = rk->GetValueNames();
   System::Collections::IEnumerator^ myEnum = valueNames->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ s = safe_cast<String^>(myEnum->Current);
      RegistryValueKind rvk = rk->GetValueKind( s );
      switch ( rvk )
      {
         case RegistryValueKind::MultiString:
         {
            array<String^>^values = (array<String^>^)rk->GetValue(
 s );
            Console::Write( "\r\n {0} ({1}) = \"{2}\"", s, rvk,
 values[ 0 ] );
            for ( int i = 1; i < values->Length;
 i++ )
            {
               Console::Write( ", \"{0}\"", values[ i ] );

            }
            Console::WriteLine();
            break;
         }
         case RegistryValueKind::Binary:
         {
            array<Byte>^bytes = (array<Byte>^)rk->GetValue( s );
            Console::Write( "\r\n {0} ({1}) = {2:X2}", s, rvk, bytes[ 0
 ] );
            for ( int i = 1; i < bytes->Length;
 i++ )
            {
               
               // Display each byte as two hexadecimal digits.
               Console::Write( " {0:X2}", bytes[ i ] );

            }
            Console::WriteLine();
            break;
         }
         default:
            Console::WriteLine( "\r\n {0} ({1}) = {2}", s, rvk, rk->GetValue(
 s ) );
            break;
      }
   }
}

import System.*;
import Microsoft.Win32.*;

public class Example
{
    public static void main(String[]
 args)
    {
        // Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueKindExample", false);
        RegistryKey rk = Registry.CurrentUser.CreateSubKey(
            "RegistryValueKindExample");
        // Create name/value pairs.
        // This overload supports QWord (long) values. 
        rk.SetValue("QuadWordValue", (Int32)42, RegistryValueKind.QWord);
        // The following SetValue calls have the same effect as using
 the
        // SetValue overload that does not specify RegistryValueKind.
        //
        rk.SetValue("DWordValue", (Int32)42, RegistryValueKind.DWord);
        rk.SetValue("MultipleStringValue", new String[]
 { "One", "Two",
            "Three" }, RegistryValueKind.MultiString);
        rk.SetValue("BinaryValue", new ubyte[] { 10,
 43, 44, 45, 14, 255 },
            RegistryValueKind.Binary);
        rk.SetValue("StringValue", "The path is %PATH%",
            RegistryValueKind.String);
        // This overload supports setting expandable string values.
 Compare
        // the output from this value with the previous string value.
        rk.SetValue("ExpandedStringValue", "The path is %PATH%"
,
            RegistryValueKind.ExpandString);
        // Display all name/value pairs stored in the test key, with
 each
        // registry data type in parentheses.
        //
        String valueNames[] = rk.GetValueNames();

        for (int iCtr1 = 0; iCtr1 < valueNames.get_Length();
 iCtr1++) {
            String s = valueNames [iCtr1];
            RegistryValueKind rvk = rk.GetValueKind(s);
            switch (rvk) {
                case RegistryValueKind.MultiString:
                    String values[] = (String[])(rk.GetValue(s));
                    Console.Write("\r\n {0} ({1}) = \"{2}\"",
 s, rvk,
                        values.get_Item(0));
                    for (int i = 1; i <
 values.get_Length(); i++) {
                        Console.Write(", \"{0}\"", values.get_Item(i));
                    }
                    Console.WriteLine();
                    break;

                case RegistryValueKind.Binary:
                    ubyte bytes[] = (ubyte[])(rk.GetValue(s));
                    Console.Write("\r\n {0} ({1}) = {2:X2}", s, rvk,
                        bytes.get_Item(0));
                    for (int i = 1; i <
 bytes.get_Length(); i++) {
                        // Display each byte as two hexadecimal digits.
                        Console.Write(" {0:X2}", bytes.get_Item(i));
                    }
                    Console.WriteLine();
                    break;

                default:
                    Console.WriteLine("\r\n {0} ({1}) = {2}", s, rvk,
                        rk.GetValue(s));
                    break;
            }
        }
    } //main
} //Example
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
RegistryKey クラス
RegistryKey メンバ
Microsoft.Win32 名前空間
GetValueNames
GetValue
SetValue
RegistryValueKind


このページでは「.NET Framework クラス ライブラリ リファレンス」からRegistryKey.GetValueKind メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRegistryKey.GetValueKind メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRegistryKey.GetValueKind メソッド を検索

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS