_is64Bit = Environment.Is64BitOperatingSystem;
private object ReadRegistryKeyValue(string keyPath, string valueName)
{
object obj = null;
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
_is64Bit ? RegistryView.Registry64 : RegistryView.Default)) // HKEY_LOCAL_MACHINE\
{
using (var pathKey = baseKey.OpenSubKey(keyPath)) // e.g:SOFTWARE\Microsoft\DirectX
{
obj= pathKey?.GetValue(valueName, null);
}
}
return obj;
//return Registry.GetValue(keyPath, valueName, null);
}
private void WriteRegistryKeyValue(string keyPath, string valueName, object value)
{
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
_is64Bit ? RegistryView.Registry64 : RegistryView.Default)) // HKEY_LOCAL_MACHINE\
{
using (var pathKey = baseKey.OpenSubKey(keyPath)) // e.g:SOFTWARE\Microsoft\DirectX
{
if (pathKey != null)
{
pathKey.SetValue(valueName, value);
}
}
}
//Registry.SetValue(keyPath, valueName, value);
}