简体   繁体   English

我如何获得注册码的真实路径?

[英]How do i get the true path to a reg key?

If you are running a 32 bit app on a 64 bit machine (I am using windows 7) and you write this code 如果您在64位计算机上运行32位应用程序(我使用的是Windows 7),则编写此代码

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\XXX")

it will actually get the key from 它实际上会从

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\XXX

and not 并不是

HKEY_LOCAL_MACHINE\SOFTWARE\XXX

Progromatically given a RegistryKey how do i work out the true path in the registry? 从农业上获得一个RegistryKey,我如何计算出注册表中的真实路径?

It is very much the True Path, a 32-bit app will always access the registry key in that subkey. 这是非常真实的路径,一个32位应用程序将始终访问该子项中的注册表项。 Getting the value that a 64-bit app would see is technically possible, just not with .NET. 从技术上来说,获得64位应用程序将看到的价值是可能的,只是.NET不能。 You'll have to P/Invoke RegOpenKeyEx() et al so you can specify the KEY_WOW64_64KEY flag. 您必须P /调用RegOpenKeyEx()等,以便可以指定KEY_WOW64_64KEY标志。


UPDATE: addressed in .NET 4.0 with RegistryKey.OpenBaseKey(). 更新:在.NET 4.0中使用RegistryKey.OpenBaseKey()解决。 The RegistryView argument lets you specify the view you want. RegistryView参数使您可以指定所需的视图。 You'd use RegistryView.Registry64 in this case. 在这种情况下,您将使用RegistryView.Registry64。

It is a function of whether or not the program was compiled for 32 or 64 bit Windows and whether it's running on 32 or 64 bit Windows. 它取决于程序是否针对32位或64位Windows编译以及是否在32位或64位Windows上运行。 See if below helps: 看看下面是否有帮助:

http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/92f962d6-7f5e-4e62-ac0a-b8b0c9f552a3 http://social.msdn.microsoft.com/Forums/zh-CN/netfx64bit/thread/92f962d6-7f5e-4e62-ac0a-b8b0c9f552a3

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

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