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

// 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值