Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WOW64: get x64 %CommonProgramFiles% from 32 bit process

Tags:

c++

winapi

wow64

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.

like image 478
peterchen Avatar asked Mar 29 '10 16:03

peterchen


1 Answers

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.

like image 196
Hans Passant Avatar answered Oct 07 '22 17:10

Hans Passant