从 WOW64 启动 Shell 链接 (LNK)
我们的 32 位应用程序通过 ShellExecute 启动 Windows LNK 文件(Shell 链接)。 当它尝试“启动”到 64 位二进制文件的链接(例如“开始”菜单中的“Internet Explorer(64 位)”快捷方式)时,它总是最终启动 32 位二进制文件。 在内部,ShellExecute 错误地解析了链接目标:LNK 内有一个隐藏字段,其中包含 FOLDERID_ProgramFiles。 64 位应用程序会将其解析为 64 位 Program Files 目录,但 32 位应用程序不会。
Wow64DisableWow64FsRedirection 不会更改 ShellExecute 的这种行为。
除了经历 64 位“蹦床”过程(由于我们的插件架构的工作方式,这不是一个选项),32 位应用程序是否有任何方法可以像 64 位应用程序一样启动 shell 链接?
Our 32-Bit application launches Windows LNK files (Shell Links) via ShellExecute. When it tries to "launch" a link to a 64-Bit binary (such as the "Internet Explorer (64-Bit)" shortcut in Start Menu) it always ends up launching the 32-Bit binary. Internally, ShellExecute incorrectly resolves the link target: There's a hidden field inside the LNK which holds FOLDERID_ProgramFiles. A 64-Bit app resolves this to the 64-Bit Program Files directory, but a 32-Bit app won't.
Wow64DisableWow64FsRedirection does not change this behavior of ShellExecute.
Besides going through a 64-Bit "trampoline" process (which is not an option due to how our plugin architecture works), Is there any way for a 32-Bit app to launch shell links exactly the way a 64-Bit app would?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Andrew:我试了一下,sysnative 文件夹不会执行 Wow64DisableWow64FsRedirection 尚未执行的任何操作。 问题是 ShellExecute 错误地假定链接指向 %programfiles(x86)%,而实际上它指向 %programfiles%(即使 %programfiles(x86)% 中没有此类文件)。
打开 64 位程序已经可以正常工作了。 问题在于指向 %programfiles% 目录的 .lnk 文件。
Andrew: I gave it a shot, and the sysnative folder does not do anything that Wow64DisableWow64FsRedirection doesn't already do. The problem is that ShellExecute mistakenly assumes that the link is pointing to %programfiles(x86)%, when it is in fact pointing to %programfiles% (Even when there is no such file in %programfiles(x86)%).
Opening 64bit programs already works perfectly fine. It's .lnk files pointing to the %programfiles% directory that are the problem.
阅读 Raymond Chen 的这篇文章 我不知道认为你所问的是可能的。 我仍然会考虑制作一个小型“蹦床”应用程序,其唯一的工作是启动给定的应用程序/链接,并编译一个不同的应用程序以在 32 位和 64 位系统上使用。 或者构建应用程序的两个版本:32 位和 64 位版本。
Reading this article from Raymond Chen I don't think what you're asking is possible. I would still consider making a small "trampoline" application, who's only job was to launch the given application/link, and compiling a different one for use on 32bit and 64bit systems. Either that or build two versions of your application, a 32bit and 64bit one.
您可以生成一个调用 LNK 的 explorer.exe 进程。
是否存在无法将程序编译为 64 位应用程序的特殊原因?
You could spawn an explorer.exe process which calls on the LNK.
Is there a particular reason you can't compile your program as a 64bit application?
任何时候你在计算机上遇到不可能的事情时,请再想一想......关键是利用 c:\windows\sysnative\ 路径来关闭重定向。
这是非常简单的代码,可以完成您想要的操作:
我希望这有帮助。
Anytime you here something is impossible on a computer, think again... The key is to utilize the c:\windows\sysnative\ path to shut off the redirection.
Here is very simple code that will do what you want:
I hope that is helpful.