WOW64: get x64 %CommonProgramFiles% from 32 bit process

peterchen picture peterchen · Mar 29, 2010 · Viewed 7.7k times · Source

Queries I tried: ExpandEnvironmentStrings("%COMMONPROGRAMFILES%"), GetSpecialPath(CSIDL_PROGRAM_FILES_COMMON).

All resolve to (typically) c:\\Program Files (x86)\\Common Files from my 32-bit app. I need to check a file version installed (typically) under c:\\Program Files\\Common Files of a 64-bit application.

Answer

Hans Passant picture Hans Passant · Mar 29, 2010

On 64-bit operating systems, the ProgramW6432 environment variable points to c:\program files. The full list for a 32-bit app on an English version of Windows:

  • ProgramFiles => c:\program files (x86)
  • ProgramFiles(x86) => c:\program files (x86)
  • ProgramW6432 => c:\program files
  • CommonProgramFiles => c:\program files (x86)\common files
  • CommonProgramFiles(x86) => c:\program files (x86)\common files
  • CommonProgramW6432 => c:\program files\common files

Just a reminder: that folder should not contain anything of interest to a 32-bit program. Technically. Beware of the file system redirector, it will redirect file requests from c:\program files to c:\program files (x86). You'd have to use Wow64DisableWow64FsRedirection() if you'd actually wanted to access files in that directory.