首页 > 其他 > 详细

获取系统版本信息和处理器信息

时间:2015-05-07 18:51:10      阅读:222      评论:0      收藏:0      [点我收藏+]
// GetSystemInfo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream>
#include <windows.h>
#include <iomanip>
using namespace std;
int main()
{
    SYSTEM_INFO systemInfo;
    GetSystemInfo(&systemInfo);

    //setw();相对于右对齐n位  setw()只对其后面紧跟的输出产生作用
    cout <<setw(20) << "处理器掩码: " << systemInfo.dwActiveProcessorMask << endl
    <<setw(20) << "处理器个数: " << systemInfo.dwNumberOfProcessors << endl
    <<setw(20) << "处理器分页大小: " << systemInfo.dwPageSize << endl
    <<setw(20) << "处理器类型: " << systemInfo.dwProcessorType << endl
    <<setw(20) << "最大寻址单元: " << systemInfo.lpMaximumApplicationAddress << endl
    <<setw(20) << "最小寻址单元: " << systemInfo.lpMinimumApplicationAddress << endl
    <<setw(20) << "处理器等级: " << systemInfo.wProcessorLevel << endl
    <<setw(20) << "处理器版本: " << systemInfo.wProcessorRevision << endl;

//  LPOSVERSIONINFOA version;
    OSVERSIONINFOEX version; //获取系统版本信息
    version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);  
    GetVersionEx((LPOSVERSIONINFOA)&version);
    cout<<"System info:"<<endl;  
    cout<<"Version:"<<version.dwMajorVersion<<"."<<version.dwMinorVersion  
        <<" Build "<<version.dwBuildNumber  
        <<" Service Pack "<<version.wServicePackMajor<<"."<<version.wServicePackMinor<<endl; 

    return 0;
}

        处理器掩码: 15
        处理器个数: 4
    处理器分页大小: 4096
        处理器类型: 586
      最大寻址单元: 7FFEFFFF
      最小寻址单元: 00010000
        处理器等级: 6
        处理器版本: 15363
System info:
Version:6.1 Build 7601 Service Pack 1.0
Press any key to continue

获取系统版本信息和处理器信息

原文:http://blog.csdn.net/djb100316878/article/details/45564197

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!