a file is located in C:\program files (x86)\my app\myexe.exe
-
FileExists(‘C:\program files (x86)\my app\myexe.exe’) returns true;
-
FileExists(‘C:\program files\my app\myexe.exe’) returns false;
in both cases, if I use Wow64DisableWow64FsRedirection or not.
Why ? Thanks
File system redirection is only there for the
%windir%\system32directory. The description of the File System Redirector seems to make this obvious.Note the comment in the page
Edit Turns out that the FOLDERID_ProgramFilesx64 does not work on 32bit applications running on 64bit windows. In this case, you can use the environment variable
%ProgramW6432%instead. Note that this variable is only available on Windows 7 and later for 32bit applications.The following delphi snippet allows accessing the variable:
Called as:
IF you’re on a 64bit version of windows, then a 32bit application cannot use
FOLDERID_ProgramFilesX64to explicitly get the 64bit location ofProgram Files, but can use the environment variable expansion instead. On a 32bit version of windows, this location is invalid, and will not get you a value. You need to check the bitness of the system before attempting to access this variable.You can use the function IsWow64Process to determine this. The following snippet should allow you to check this:
In summary:
FOLDERID_ProgramFilesgives you the 32/64 bit variant when accessed from a 32/64 bit program,FOLDERID_ProgramFilesX64gives you the 64bit version explicitly on a 64-bit application, andFOLDERID_ProgramFilesX86gives you the 32bit variant explicitly. You can use the environment variable expansion to get the 64bit value on a 32bit application