码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-05-07 18:54:18      阅读:137      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!