我们可以创建一个 VC++可以在 32 位和 64 位 Windows 上本机运行的可执行文件吗?
有没有办法构建一个 VC++ 项目,以便它创建的 dll/exe 在 32 位 Windows 操作系统上作为 32 位应用程序运行,在 64 位 Windows 操作系统上作为 64 位应用程序运行(不在 WOW64 中)。
我知道对于使用 /ANYCPU 选项的 C# 应用程序来说这是可能的。
Is there any way to build a VC++ project so that the dll/exe created by it will work as a 32 bit application on a 32 bit Windows OS and as a 64 bit application on a 64 bit Windows OS (not in WOW64).
I know that is possible for C# applications using the /ANYCPU option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CLR 对 /ANYCPU 选项有特殊的加载程序支持。
如果您确实想对本机执行此操作,最好的方法是:
就是 Sysinternals 工具的工作原理(将 Process Explorer 下载到64 位机器并运行它:您会看到它将 procexp64.exe 写入磁盘,然后从那里运行它)。这是一个 hack,但它确实有效。
The CLR has special loader support for the /ANYCPU option.
If you really want to do this for native, the best way to do it is to:
This is how the Sysinternals tools work (download Process Explorer onto a 64-bit machine and run it: you'll see that it writes procexp64.exe to disk and then runs it from there). It's a hack, but it works.
不是 AFAIK - 问题是
对于 .EXE,您可以做的最好的事情就是发送一个 32 位 .exe,检查它是否正在运行 WOW64,然后生成 64 位版本。不过,我想不出库的等效技巧 - 它必须首先匹配要加载的主机进程的位。
Not AFAIK - the problem is that
The best you could do for an .EXE was to ship a 32-bit .exe that checks if it's running WOW64 then spawns the 64-bit version instead. I can't think of an equivalent trick for libraries, though - it has to match the bits of the host process to load in the first place.