c# - SetValue 64 位机器注册表

标签 c# .net installation registry 64-bit

我想在下面的注册表路径中为“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/

相关文章:

c# - 我如何从最后循环遍历列表?

c# - 如何将表格添加到托盘

c# - 为什么 Columns 在调用 DataGridView.Columns.Clear() 后不保持隐藏状态?

c# - 为什么 "new CultureInfo("xx")"在一种环境中引发异常,而在另一种环境中则不会?

windows - 如何在单击按钮时跳至页面上?

node.js - 什么是全局安装 devDependencies 的 npm 命令?

c++ - 使用代码块在 Windows 上安装 boost

c# - 将 Shift+1 检测为 Key.Add

c# - 在 C# 中通过 COM Interop 编码字符串时编码失败(双 UTF8 编码?)

.net - .NET内存 "Gen X Heap Size".NET性能计数器到底能测量什么?