SetValue 64位计算机注册表 [英] SetValue 64bit machine registry

查看:92
本文介绍了SetValue 64位计算机注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在下面的注册表路径中为 NoModify设置一个值。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XXXX

I want to set a value for 'NoModify' in below registry path. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XXXX"

我正在使用以下代码,它仅适用于X86机器。您能看到什么原因对于x64机器不起作用吗?

I am using below code and it works only for X86 machines. Can you see any reason why this is not working for x64 machines?

// 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();
        }
    }


推荐答案

我在代码中的错误。

RegistryView registryView = releaseFlags.Contains("PLATFORM_X86") ? RegistryView.Registry64 : RegistryView.Registry32;

应如下所示:

RegistryView registryView = releaseFlags.Contains("PLATFORM_X86") ? RegistryView.Registry32 : RegistryView.Registry64;

这篇关于SetValue 64位计算机注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆