RegistryValueKind 列挙体とは? わかりやすく解説

RegistryValueKind 列挙体

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

レジストリに値を格納するときに使用するデータ型指定するか、レジストリ内の値のデータ型識別します。

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

<ComVisibleAttribute(True)> _
Public Enumeration RegistryValueKind
Dim instance As RegistryValueKind
[ComVisibleAttribute(true)] 
public enum RegistryValueKind
[ComVisibleAttribute(true)] 
public enum class RegistryValueKind
/** @attribute ComVisibleAttribute(true) */ 
public enum RegistryValueKind
ComVisibleAttribute(true) 
public enum RegistryValueKind
メンバメンバ
 メンバ説明
.NET Compact Framework によるサポートBinary任意の形式バイナリ データ指定します。この値は、Win32 API の REG_BINARY レジストリ データ型相当します。 
.NET Compact Framework によるサポートDWord32 ビットバイナリ数値指定します。この値は、Win32 API の REG_DWORD レジストリ データ型相当します。 
.NET Compact Framework によるサポートExpandString値を取得するときに展開される環境変数 (%PATH% など) への、展開されていない参照含まれている null で終わる文字列指定します。この値は、Win32 API の REG_EXPAND_SZ レジストリ データ型相当します。 
.NET Compact Framework によるサポートMultiStringnull で終わる文字列配列指定します配列は、2 つnull 文字終わります。この値は、Win32 API の REG_MULTI_SZ レジストリ データ型相当します。 
.NET Compact Framework によるサポートQWord64 ビットバイナリ数値指定します。この値は、Win32 API の REG_QWORD レジストリ データ型相当します。 
.NET Compact Framework によるサポートStringnull で終わる文字列指定します。この値は、Win32 API の REG_SZ レジストリ データ型相当します。 
.NET Compact Framework によるサポートUnknownサポートされていないレジストリ データ型示します。たとえば、Microsoft Win32 API の REG_RESOURCE_LIST レジストリ データ型サポートされていません。この値を使用して、名前と値のペア格納するときに、SetValue メソッド適切なレジストリ データ型決定する必要があることを指定します。 
解説解説
使用例使用例

レジストリ キー作成しRegistryValueKind によってレジストリ データ型指定して作成したキー複数の値を設定するコード例次に示します。この例では、値を取得して表示するために、RegistryKey.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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Microsoft.Win32 名前空間
GetValueKind
SetValue


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

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

辞書ショートカット

すべての辞書の索引

「RegistryValueKind 列挙体」の関連用語

RegistryValueKind 列挙体のお隣キーワード
検索ランキング

   

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



RegistryValueKind 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS