How to determine if a WOW64 registry key has been reassigned?
Can you tell if a given registry key has been redirected?
My problem is that I want to list registry keys in both 32-bit and 64-bit registry views in a generic way from a 32-bit application. I could just open each key twice, first with KEY_WOW64_64KEY and then with KEY_WOW64_32KEY. However, if the key is not redirected, it gives you exactly the same key, and you end up listing the same content twice; this is what I am trying to avoid.
I found the documentation on it , but it looks like the only way is to examine the hive and do a series of string comparisons per key. Another possibility I was thinking about is to try to open the Wow6432Node in each subsection; if it exists, then the key must be redirected. That is, if I try to open HKCU \ Software \ Microsoft \ Windows, I try to open the following keys: HKCU \ Wow6432Node, HKCU \ Software \ Wow6432Node, HKCU \ Software \ Microsoft \ Wow6432Node, and HKCU \ Software \ Microsoft \ Windows \ Wow6432Node. Unfortunately, the documentation seems to imply that the child of the redirected key is not necessarily redirected, so the route has problems as well.
So what are my options here?
a source to share
Your purpose is not clear. Why would you need to list registry keys in both 32-bit and 64-bit registry views in a generic way from a 32-bit application? What do you want to do with 64-bit values in your application? What would you do if there are multiple values for x64 and x86? This seems like a strange or rather the wrong idea.
Keys are redirected for an important reason: do not break the behavior of x86 applications. For example: CLSID
Used by COM to find the correct implementation for a given interface. Among other things, "correct" means that it can be controlled by the caller ID, that is, it must be on the same platform. This is why there must be different recordsets for x64 and x86. The reasons for other redirected keys are similar. Generally speaking, these redirected keys should be different for x86 and x64 applications.
As Raymond Chen wrote, " On 64-bit Windows, 32-bit programs run at the emulation layer, and if you don't like that, then don't use the emulator, " and I totally agree with his advice. So my best advice if you need something like this is to do it from an x64 app. But first, change your mind if you really need it.
EDIT: Parameter you samDesired
RegOpenKeyEx
might find useful. Also consider Accessing an Alternate Registry View . MSDN article.
a source to share
You have a lot of misery, it depends on the version of the operating system. A complete list is available here .
a source to share