C++ 判断操作系统位数

方法一:

#include <windows.h>
#include<iostream>
using namespace std;

BOOL is64bitSystem()
{
	SYSTEM_INFO si;
	GetNativeSystemInfo(&si);
	if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
		si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
		return TRUE;
	return FALSE;
}

int main()
{
	if (is64bitSystem())
		cout << "The process is running under WOW64.\n";
	else
		cout << "The process is not running under WOW64.\n";
	return 0;
}

方法二:

#include<iostream>
using namespace std;

int main()
{
	void* p = 0;
	cout << sizeof(p) * 8 << endl;
	return 0;
}
发布了56 篇原创文章 · 获赞 2 · 访问量 1596

猜你喜欢

转载自blog.csdn.net/baidu_41793719/article/details/104482794
今日推荐