RegistryValueKind 列挙体
アセンブリ: mscorlib (mscorlib.dll 内)

<ComVisibleAttribute(True)> _ Public Enumeration RegistryValueKind

メンバ名 | 説明 | |
---|---|---|
![]() | Binary | 任意の形式のバイナリ データを指定します。この値は、Win32 API の REG_BINARY レジストリ データ型に相当します。 |
![]() | DWord | 32 ビットのバイナリ数値を指定します。この値は、Win32 API の REG_DWORD レジストリ データ型に相当します。 |
![]() | ExpandString | 値を取得するときに展開される環境変数 (%PATH% など) への、展開されていない参照が含まれている null で終わる文字列を指定します。この値は、Win32 API の REG_EXPAND_SZ レジストリ データ型に相当します。 |
![]() | MultiString | null で終わる文字列の配列を指定します。配列は、2 つの null 文字で終わります。この値は、Win32 API の REG_MULTI_SZ レジストリ データ型に相当します。 |
![]() | QWord | 64 ビットのバイナリ数値を指定します。この値は、Win32 API の REG_QWORD レジストリ データ型に相当します。 |
![]() | String | null で終わる文字列を指定します。この値は、Win32 API の REG_SZ レジストリ データ型に相当します。 |
![]() | Unknown | サポートされていないレジストリ データ型を示します。たとえば、Microsoft Win32 API の REG_RESOURCE_LIST レジストリ データ型はサポートされていません。この値を使用して、名前と値のペアを格納するときに、SetValue メソッドで適切なレジストリ データ型を決定する必要があることを指定します。 |

RegistryValueKind 列挙体は、サポートされている一連のレジストリ データ型、およびサポートされていないデータ型 (Unknown) に使用する値を定義します。
レジストリ キー値を取得する前にその値のデータ型を決定するには、RegistryKey.GetValueKind メソッドを使用します。レジストリ キー値を設定するときに、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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からRegistryValueKind 列挙体を検索する場合は、下記のリンクをクリックしてください。

- RegistryValueKind 列挙体のページへのリンク