[C/C++]_[判断程序是32位还是64位]
2016-03-28 12:54
489 查看
http://blog.csdn.net/infoworld/article/details/10958583
场景:
1.编译器没有显式的指定。
2.需要根据32,64做不同的处理.
方法1:
[cpp] view
plain copy
#include "stdio.h"
int main(int argc,char * argv[])
{
void* number = 0;
printf("%d\n",sizeof(&number));
}
输出8就是64位的,4就是32位的。根据逻辑地址判断。
方法2:
可以用file命令判断(如果安装了msys的话,linux下应该自带)
file msys-expat-1.dll
[plain] view
plain copy
msys-expat-1.dll: PE executable for MS Windows (DLL) (console) Intel 80386 32-bi
t
方法3:
[plain] view
plain copy
If you have a hex editor program, just open your file with it and shortly after the standard header intro stuff (like
"This program cannot be run in DOS mode...") you will see either
"PE..L" (hex code: 504500004C) = 32 bit
or
"PE..d†" (hex code: 504500006486) = 64 bit
随手UE打开了两个exe,果然有效。但是这个50450000????的位置不确定,大致在00000100h附近。
另 exe 文件头的典型提示字串未必统一。如一个是This program cannot be run in DOS mode,另一个是
This program must be run under Win32
原文
方法4:
vs的工具dumpbin,参数/HEADERS
64 bit
[plain] view
plain copy
E:\software\TDM-GCC-64\bin>dumpbin /HEADERS libgcc_s_seh_64-1.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file libgcc_s_seh_64-1.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
8664 machine (x64)
32 bit
[plain] view
plain copy
E:\software\TDM-GCC-64\bin>dumpbin /HEADERS g++.exe
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file g++.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
14C machine (x86)
场景:
1.编译器没有显式的指定。
2.需要根据32,64做不同的处理.
方法1:
[cpp] view
plain copy
#include "stdio.h"
int main(int argc,char * argv[])
{
void* number = 0;
printf("%d\n",sizeof(&number));
}
输出8就是64位的,4就是32位的。根据逻辑地址判断。
方法2:
可以用file命令判断(如果安装了msys的话,linux下应该自带)
file msys-expat-1.dll
[plain] view
plain copy
msys-expat-1.dll: PE executable for MS Windows (DLL) (console) Intel 80386 32-bi
t
方法3:
[plain] view
plain copy
If you have a hex editor program, just open your file with it and shortly after the standard header intro stuff (like
"This program cannot be run in DOS mode...") you will see either
"PE..L" (hex code: 504500004C) = 32 bit
or
"PE..d†" (hex code: 504500006486) = 64 bit
随手UE打开了两个exe,果然有效。但是这个50450000????的位置不确定,大致在00000100h附近。
另 exe 文件头的典型提示字串未必统一。如一个是This program cannot be run in DOS mode,另一个是
This program must be run under Win32
原文
方法4:
vs的工具dumpbin,参数/HEADERS
64 bit
[plain] view
plain copy
E:\software\TDM-GCC-64\bin>dumpbin /HEADERS libgcc_s_seh_64-1.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file libgcc_s_seh_64-1.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
8664 machine (x64)
32 bit
[plain] view
plain copy
E:\software\TDM-GCC-64\bin>dumpbin /HEADERS g++.exe
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file g++.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
14C machine (x86)
相关文章推荐
- c++实验2-标准体重
- 设计模式--适配器模式C++实现
- 利用JNI技术在Android中调用C++形式的OpenGL ES 2.0函数
- C++之const和引用操作符&
- C++中STL迭代器的种类和简介
- 设计模式--策略模式C++实现
- C++ template
- 【C/C++语言入门篇】-- 位运算
- Windows驱动开发:用C还是C++
- c++ stl 五种迭代器
- eclipse c++如果debug的时候,遇到no source for main
- eclipse c++ 遇到error while loading .....某某lib的问题
- c++ map 用例
- c++中map用法
- C++ 判断磁盘是否为可移动磁盘
- c++作业2
- C语言实现封装、继承和多态
- 2013级C++第15周(春)项目——输入输出流及文件文件操作
- C++获得系统路径
- 设计模式--装饰模式C++实现