google is not helping me today, so i need your help. Is there a possible way to read a value from a registry ? example this location --> HKEY_LOCAL_MACHINE > SOFTWARE > MyKey the column is Test key
64bit + 32bit
using Microsoft.Win32;
public static string GetRegistry()
{
string registryValue = string.Empty;
RegistryKey localKey = null;
if (Environment.Is64BitOperatingSystem)
{
localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
}
else
{
localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
}
try
{
localKey = localKey.OpenSubKey(@"Software\\MyKey");
registryValue = localKey.GetValue("TestKey").ToString();
}
catch (NullReferenceException nre)
{
}
return registryValue;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With