10秒で理解するWindowsのバイナリがx86かx64なのかを確認する方法

dumpbin /headers で machine の値を確認すればよい。
exe、dll、lib、objに対して確認することができる。
(dumpbinはVisual Studioに付属している。)

x64の例

  • exeの場合
    D:\JDK\JDK1.6.0_13_x64>dumpbin /headers bin\java.exe|findstr machine
                8664 machine (x64)
  • dllの場合
    D:\JDK\JDK1.6.0_13_x64>dumpbin /headers jre\bin\java.dll |findstr machine
                8664 machine (x64)
  • libの場合
    D:\JDK\JDK1.6.0_13_x64>dumpbin /headers lib\jvm.lib|findstr machine
                8664 machine (x64)
                8664 machine (x64)
                8664 machine (x64)
  • objの場合
    D:\temp\test\x64>dir /b
    helloworld.c
    helloworld.exe
    helloworld.obj
    
    D:\temp\test\x64>dumpbin /headers *obj|findstr machine
                8664 machine (x64)

x86の例

  • exeの場合
    D:\JDK\JDK1.6.0_06-b02>dumpbin /headers bin\java.exe|findstr machine
                 14C machine (x86)
                       32 bit word machine
  • dllの場合
    D:\JDK\JDK1.6.0_06-b02>dumpbin /headers jre\bin\java.dll |findstr machine
                 14C machine (x86)
                       32 bit word machine
  • libの場合
    D:\JDK\JDK1.6.0_06-b02>dumpbin /headers lib\jvm.lib|findstr machine
                 14C machine (x86)
                       32 bit word machine
                 14C machine (x86)
                       32 bit word machine
                 14C machine (x86)
                       32 bit word machine
  • objの場合
    D:\temp\test\x86>dir /b
    helloworld.c
    helloworld.exe
    helloworld.obj

    D:\temp\test\x86>dumpbin /headers *obj|findstr machine
                 14C machine (x86) 


そういえば、APIの非互換とかはまりそうなことはたくさんあるのに、
Windowsのx64開発用の書籍ってあまり見かけないよね。

Win64APIシステムプログラミング―64ビット徹底活用
北山 洋幸
カットシステム
売り上げランキング: 90140



Windowsで開発と言えばこれだね。

Advanced Windows 第5版 上 (マイクロソフト公式解説書)
Jeffrey Richter Christophe Nasarre
日経BPソフトプレス
売り上げランキング: 103295


Advanced Windows 第5版 下 (マイクロソフト公式解説書)
Jeffrey Richter Christophe Nasarre
日経BPソフトプレス
売り上げランキング: 106508