public GetValueKind ( string name ) : Microsoft.Win32.RegistryValueKind | ||
name | string | |
return | Microsoft.Win32.RegistryValueKind |
using Microsoft.Win32; RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\MyApp"); string myString = key.GetValue("MyString") as string; if (myString != null) { RegistryValueKind kind = key.GetValueKind("MyString"); Console.WriteLine($"MyString is a {kind} value"); }
using Microsoft.Win32; RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\MyApp"); byte[] myBinary = key.GetValue("MyBinary") as byte[]; if (myBinary != null) { RegistryValueKind kind = key.GetValueKind("MyBinary"); Console.WriteLine($"MyBinary is a {kind} value"); }In this example, we read a binary value from the registry and use the GetValueKind() method to determine its data type. The method returns a RegistryValueKind enumeration value, which we print to the console. Package library: Microsoft.Win32.Registry Overall, the RegistryKey.GetValueKind() method is a useful tool for developers who need to read values from the Windows Registry and determine their data types. The method is part of the Microsoft.Win32.Registry namespace, which is included in the .NET Framework class library.
public GetValueKind ( string name ) : Microsoft.Win32.RegistryValueKind | ||
name | string | |
return | Microsoft.Win32.RegistryValueKind |