开发者

Accessing Registry on windows 7 C#

开发者 https://www.devze.com 2023-03-22 15:27 出处:网络
I am attempting to make an updater program, that when updates it writes a build number into the windows 7 registry which th开发者_如何学运维e main program reads when checking for updates. I\'ve gone t

I am attempting to make an updater program, that when updates it writes a build number into the windows 7 registry which th开发者_如何学运维e main program reads when checking for updates. I've gone through the UAC virtualization kb at microsoft's page, and have found nothing. My app.manifest has

<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.

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:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ or 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.

For more information see Registry Reflection

0

精彩评论

暂无评论...
验证码 换一张
取 消