WOW64 woes (.lnk shortcuts)

*爱你&永不变心* 提交于 2019-12-05 12:30:05
Giel

I think you should call Wow64DisableWow64FsRedirection before and Wow64RevertWow64FsRedirection aftyer.

Ok, a small example that demonstrates the problem.

I invoke ShellExecute with the following parameters:

ShellExecute(Handle, 'open', 'C:\Users\...\Internet Explorer (64-bit).lnk', nil, nil, SW_SHOWNORMAL);

The target of Internet Explorer (64-bit).lnk is:

C:\Program Files\Internet Explorer\iexplore.exe

However, the 32-bit version of iexplore.exe is opened nonetheless. In this case the path doesn't even use %ProgramFiles%, so somehow ShellExecute will translate C:\Program Files to C:\Program Files (x86) internally. I have no idea how to make it open the 64-bit version of iexplore.exe instead.

Another problem, after calling Wow64DisableWow64FsRedirection, ShellExecute will no longer open folders.

The following environment variables will always point to the right direction on a 64-bit machine, and will be undefined on a 32-bit machine:

from a 32-bit shell on a 32-bit architecture:

C:\>echo %processor_architecture%
x86
C:\>echo %programfiles(x86)%
%programfiles(x86)%
C:\>echo %programw6432%
%programw6432%
C:\>echo %programfiles%
C:\Program Files

from a 32-bit shell on a 64-bit architecture:

C:\>echo %processor_architecture%
x86
C:\>echo %programfiles(x86)%
C:\Program Files (x86)
C:\>echo %programw6432%
C:\Program Files
C:\>echo %programfiles%
C:\Program Files (x86)

from a 64-bit shell:

C:\>echo %processor_architecture%
AMD64
C:\>echo %programfiles(x86)%
C:\Program Files (x86)
C:\>echo %programw6432%
C:\Program Files
C:\>echo %programfiles%
C:\Program Files

Try substituting them before running the application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!