As explained in MSDN's WOW64 Implementation Details, the variable %PROGRAMFILES%
,
in a 32-bit-process on a 64-bit-Windows OS, resolves to
C:\Program Files (x86)
in a 64-bit-process on a 64-bit-Windows OS, resolves to
C:\Program Files
You can verify this e.g. with a Delphi 10.1 program, compiled both with the 32-bit Windows Target Platform and with the 64-bit Windows Target Platform:
MyShellExecute('%PROGRAMFILES%');
So, from a 32-bit Delphi Application executed in a Windows-64bit-OS, how can I get BOTH:
the ProgramFiles directory for 32-bit-Programs (
C:\Program Files (x86)
)the ProgramFiles directory for 64-bit-Programs (
C:\Program Files
)