我想在下面的注册表路径中为“NoModify”设置一个值。 "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XXXX"
我正在使用下面的代码,它只适用于 X86 机器。您能看出这不适用于 x64 机器的任何原因吗?
// This value is correct
RegistryView registryView = releaseFlags.Contains("PLATFORM_X86") ? RegistryView.Registry64 : RegistryView.Registry32;
using (RegistryKey hkeyLocalMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView))
{
RegistryKey noModifyKey = hkeyLocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{xxxx}", true); //SL: Key Name
if (noModifyKey != null)
{
noModifyKey.SetValue("NoModify", 0);
noModifyKey.Flush();
}
}
最佳答案
当您使用的是 64 位机器而您的应用程序是 32 位时 - 它应该将这些设置存储在 HKLM\Software\WOW6432Node 而不是 HKLM\Software\节点中。
关于c# - SetValue 64 位机器注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13337577/