如何确定我正在安装的应用程序是 32 位还是 64 位?
我希望能够预测应用程序的默认安装位置。在 64 位计算机上,如果它是 32 位应用程序,它将安装在“Program Files (x86)”中,如果它是 64 位应用程序,它将安装在“Program Files”中。
我的目标是使用默认位置安装应用程序并验证安装是否正常。但为此我需要知道它将安装在哪里。如果我知道应用程序是为什么架构构建的,我认为它会达到我的目的。
I want to be able to predict the default install location of an application. On a 64-bit machine, if it is a 32-bit application, it would install in "Program Files (x86)" and if it were a 64-bit application, it would install in "Program Files".
My goal is to install the application with its default location and validate if the install was fine. But for this I need to know where it would be installed. If I know what architecture the application is built for, I think it would serve my purpose.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以使用外部工具,则 GNU
file
是最通用的解决方案。但对于这个目的来说可能有点矫枉过正了。其他替代方案是 Dependency Walker、Sysinternals 的 Sigcheck、MSVC 的 dumpbin 或 corflags...但可能让很多人感到惊讶的是 7zip。它内部有一个类似file
的小实用程序,可以与l
选项一起使用。如果您必须自己检查它,则读取文件中偏移量0x3C处的2个字节。然后将该值加 4 并在该偏移处读取 2 个字节,这将指示体系结构。例如,在下面的示例中,文件在偏移量 0x3C 处包含 0x00E0。在偏移量 0x00E0 + 4 = 0x00E4 处包含0x8664,这意味着 64 位二进制数。如果它是 32 位 x86 二进制文件,那么它将包含 0x014C
您可以在下面的链接中找到更多方法。还有其他 PowerShell 和 VBS 脚本可用于此目的
If you can use external tools then GNU
file
is the most versatile solution. But it might be a bit overkill for this purpose. Other alternatives being Dependency Walker, Sysinternals' Sigcheck, MSVC's dumpbin or corflags... But the one that might surprise a lot of people is 7zip. It has a smallfile
-like utility inside that can be used withl
optionIf you have to check it yourself then read 2 bytes at offset 0x3C in the file. Then add 4 to this value and read 2 bytes at that offset, that'll indicate the architecture. For example in the below example the file contains 0x00E0 at offset 0x3C. At offset 0x00E0 + 4 = 0x00E4 contains 0x8664 which means a 64-bit binary. If it was a 32-bit x86 binary then it will contain 0x014C
There are more ways that you can find in the below links. There are also other PowerShell and VBS scripts available for that purpose
下载适用于 Windows 的
file
以检查 Windows 上任何文件的详细信息:http ://gnuwin32.sourceforge.net/packages/file.htm
然后,通过 Windows 命令行:
您应该能够从您使用的任何开发平台获取此命令的返回值。
Download
file
for Windows to check the details of any file on Windows:http://gnuwin32.sourceforge.net/packages/file.htm
Then, via the Windows command line:
You should be able to grab the return value of this command from whatever development platform your working with.