0
votes

I have Delphi XE4 installed on a machine running Windows 7, 64 bit. I was trying to traverse the following two registry keys:

  1. HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
  2. HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

I wrote a simple program that traverses all the subkeys within each of the above registry keys. When I set the target system to be 32Bit, XE4 ignores registry key #1 and gives me the information from registry key #2 instead. When I set the target system to be 64Bit, XE4 recognizes both registry keys as separate and distinct and returns two different sets of data.

Why does XE4 ignore registry key #1 and substitute key #2 instead when the target system is set to 32Bit? Is there a way to read key #1 when targeting a 32Bit system?

This makes me think there are other registry keys that XE4-32Bit performs some hidden substitute on.

1
This is called Registry RedirectorRRUZ
And it has the same reason as the Program Files redirectionSir Rufo
Because while the target is 32 bit, you are running it on 64 bit system, yours. If you ran your app on a 32 bit OS it would only hit node 1. If your target was 64 and you'd never done a 32 bit app, there would be no entry in WOW6432, and you'd still only hit node 1. So what you are seeing is what happens when you have 64 and 32 bit versions of the same app installed.Tony Hopkinson
@SirRufo There is no Program Files redirection. There is system32 redirection. That's the file system redirector.David Heffernan

1 Answers

2
votes

This is nothing to do with Delphi. This is all about Windows, and specifically the WOW64 emulator that runs 32 bit processes on 64 bit Windows.

A 32 bit process, running under WOW64 on a 64 bit machine is presented with the 32 bit view of certain registry keys. This is handled transparently by the registry redirector. Do follow that MSDN link to learn more about the redirector, and take special heed of the section that tells you never to access Wow6432Node directly.

You can see into different views of the registry like this:

  • A 32 bit process can access the 64 bit registry view using the KEY_WOW64_64KEY flag.
  • A 64 bit process can access the 32 bit registry view using the KEY_WOW64_32KEY flag.

This is covered in more detail on MSDN: Accessing an Alternate Registry View.

In Delphi, you can specify these flags when creating an instance of TRegistry, or through the Access property.