65.9K
CodeProject 正在变化。 阅读更多。
Home

如何判断可执行文件是 32 位还是 64 位

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (8投票s)

2016年1月12日

CPOL

1分钟阅读

viewsIcon

24174

如何判断可执行文件是 32 位还是 64 位

引言

通常情况下,我们会遇到一个问题,需要判断应用程序或可执行文件是否与 32 位或 64 位版本兼容。

基本上,有两种方法:

  1. 微软 Visual Studio 提供的 dumpbin.exe
  2. 任何十六进制编辑器

背景

第一种方法

强制要求事先安装了微软 Visual Studio。

启动 Visual Studio 命令提示符(建议使用管理员模式

前往

开始 > 所有程序 > Microsoft Visual Studio(任何版本,可能 >= 2008)> Visual Studio 工具 > Visual Studio 命令提示符

然后,“以管理员身份运行”。

dumpbin.exe 复制到应用程序(EXE)所在的文件夹中,然后运行以下命令:

>dumpbin.exe /headers <executable/exe/bin> | findstr "magic machine"

如果是 32 位:            machine (x86)

如果是 64 位:            machine (x64)

第二种方法

强制要求使用任何十六进制编辑器(可以使用 notepad++)。

注意:也可以使用在线十六进制编辑器。

使用十六进制编辑器(在本例中为 notepad++)打开应用程序或 EXE 文件,并找到 “PE..” (通常在数据的最初 256 个字节中找到)。

如果是 32 位:            PE..L.. (十六进制代码:504500004Cxxxx) = 32 位

如果是 64 位:            PE..d.. (十六进制代码:504500006486xx) = 64 位

Using the Code

示例

D:\Software\eclipse-jee-luna-R-win32-x86_64\eclipse>dumpbin.exe /headers eclipse.exe | 
	findstr "magic machine"

            8664 machine (x64)

             20B magic # (PE32+)

D:\Software>dumpbin.exe /headers jxpiinstall.exe | findstr "magic machine"

             14C machine (x86)

                   32 位字机器

             10B magic # (PE32)

示例

jxpiinstall.exe

PE..L.. (十六进制代码:504500004Cxxxx) = 32 位

或者

eclipse.exe

PE..d.. (十六进制代码:504500006486xx) = 64 位

关注点

十六进制编辑器链接

© . All rights reserved.