简体   繁体   English

访问 windows 7 C# 上的注册表

[英]Accessing Registry on windows 7 C#

I am attempting to make an updater program, that when updates it writes a build number into the windows 7 registry which the main program reads when checking for updates.我正在尝试制作一个更新程序,它在更新时将内部版本号写入 windows 7 注册表,主程序在检查更新时读取该注册表。 I've gone through the UAC virtualization kb at microsoft's page, and have found nothing.我已经浏览了微软页面上的 UAC 虚拟化 kb,但一无所获。 My app.manifest has我的 app.manifest 有

<requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

and yet, when i look in HKEY_Local_Machine\Software the build entry is not there, i dont even see it in HKEY_USERS\_Classes\VirtualStore\Machine\Software either.然而,当我查看 HKEY_Local_Machine\Software 时,构建条目不存在,我什至在 HKEY_USERS\_Classes\VirtualStore\Machine\Software 中也看不到它。

the code i'm using to enter into registry is我用来进入注册表的代码是

            Registry.LocalMachine.CreateSubKey("SOFTWARE\\build");
        RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\build", true);

        myKey.SetValue("build", "3", RegistryValueKind.String);

any ideas/suggestions?有什么想法/建议吗?

If your application is targetting x86 platforms, when running on an x64 system, it will use the corresponding registry node with the following names:如果您的应用程序面向 x86 平台,则在 x64 系统上运行时,它将使用具有以下名称的相应注册表节点:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ or HKEY_CURRENT_USER\SOFTWARE\Wow6432Node. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ 或 HKEY_CURRENT_USER\SOFTWARE\Wow6432Node。

So, if you set platform target to x86 for your build, on x86 systems it will go under HKEY_LOCAL_MACHINE\SOFTWARE whereas on x64 systems it will go under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node which is a reserved node for applications running on WOW64(Windows 32-bit on Windows 64-bit) mode. So, if you set platform target to x86 for your build, on x86 systems it will go under HKEY_LOCAL_MACHINE\SOFTWARE whereas on x64 systems it will go under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node which is a reserved node for applications running on WOW64(Windows 32- Windows 64 位)模式上的位。

For more information see Registry Reflection有关更多信息,请参阅注册表反射

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM