RegistryKey.GetValueKind メソッド
アセンブリ: 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)
戻り値
name に関連付けられた値のレジストリ データ型を表す RegistryValueKind 値。

例外の種類 | 条件 |
---|---|
SecurityException | |
ObjectDisposedException | |
IOException | または この例外は、Windows 95、Windows 98、および Windows Millennium Edition ではスローされません。 |
UnauthorizedAccessException |

![]() |
---|
レジストリ キーは、名前の関連付けられていない値を 1 つ保持できます。この無名の値がレジストリ エディタに表示されるときには、名前の代わりに "(既定)" という文字列が表示されます。この無名の値のレジストリ データ型を取得するには、name に null 参照 (Visual Basic では Nothing) または空の文字列 ("") を指定します。 |
サポートされるレジストリ データ型の説明については、RegistryValueKind 列挙体のトピックを参照してください。

テスト キーを作成し、このキーにさまざまなデータ型の値を追加するコード例を次に示します。さらに、この例では 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に収録されているすべての辞書からRegistryKey.GetValueKind メソッドを検索する場合は、下記のリンクをクリックしてください。

- RegistryKey.GetValueKind メソッドのページへのリンク