Starting from .Net 4.0, there is actually RegistryView used for this purpose. For any .Net version earlier than that, here is the rule:
"The rules are pretty straightforward:
- .NET app compiled for "x86":
- Always 32-bit
- On 32-bit platforms, accesses 32-bit registry
- On 64-bit platforms, accesses 32-bit registry (inside Wow6432Node)
- 64-bit registry inaccessible (without doing something weird)
- .NET app compiled for "x64":
- Always 64 bit
- On 32-bit platforms, won't run
- On 64-bit platforms, accesses 64-bit registry (not inside Wow6432Node)
- If you want to get to the 32-bit registry, you need to do something weird
- .NET app compiled for "AnyCpu"
- Either 32 or 64 bit depending on platform
- On 32-bit platforms, accesses 32-bit registry
- On 64-bit platforms, accesses 64-bit registry (not inside Wow6432Node)
- If you want to get to the 32-bit registry, you need to do something weird
"Something weird" technically requires passing a special flag to RegOpenKeyEx to obtain the alternate registry view. .NET doesn't expose any function that will do this nicely, so you'd have to drop to p/invoke to get there."
Reference: http://social.msdn.microsoft.com/forums/en-US/netfx64bit/thread/92f962d6-7f5e-4e62-ac0a-b8b0c9f552a3
No comments:
Post a Comment