(1)获取系统位数32bit 64bit
void CXXXDlg::GetSysBit(bool& bIs32Bit)
{
bIs32Bit=true;
SYSTEM_INFO si;
// Copy the hardware information to the SYSTEM_INFO structure.
GetNativeSystemInfo(&si);
// Display the contents of the SYSTEM_INFO structure.
printf("si.wProcessorArchitecture = %d\nPROCESSOR_ARCHITECTURE_AMD64 = %d\nPROCESSOR_ARCHITECTURE_IA64 = %d\n",
si.wProcessorArchitecture, PROCESSOR_ARCHITECTURE_AMD64, PROCESSOR_ARCHITECTURE_IA64);
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
{
bIs32Bit=false;
}
else{
bIs32Bit=true;
}
}
前面的博文中已经对Windows操作系统产品名与内部版本号的对应做了总结,参考:http://blog.csdn.net/shufac/article/details/52088374
通过下面的函数可以获取版本相关的信息,函数如下:
void CXXXDlg::GetSysType(DWORD& dwMajorVersion,DWORD& dwMinorVersion)
{
//DWORD dwOSVersionInfoSize;//
//DWORD dwMajorVersion;//主版本号
//DWORD dwMinorVersion;//副版本
//DWORD dwBuildNumber;//创建号
//DWORD dwPlatformId;//ID号
//WCHAR szCSDVersion[ 128 ]; //
dwMajorVersion=0;
dwMinorVersion=0;
OSVERSIONINFO osvi; //定义OSVERSIONINFO数据结构对象
memset(&osvi, 0, sizeof(OSVERSIONINFO)); //开空间
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); //定义大小
GetVersionEx (&osvi); //获得版本信息
dwMajorVersion=osvi.dwMajorVersion;
dwMinorVersion=osvi.dwMinorVersion;
}