获得CPU的信息

来源:互联网 发布:现在淘宝上视频 编辑:程序博客网 时间:2024/05/23 19:19

#include <conio.h>
#include <iostream>

#pragma hdrstop
#pragma inline
//#pragma argsused

using namespace std;

int main()
{
 char OEMString[13];

 int iEAXValue, iEBXValue, iECXValue, iEDXValue;

 _asm
 {
  mov eax, 0
  cpuid
  mov DWORD PTR OEMString, ebx
  mov DWORD PTR OEMString + 4, edx
  mov DWORD PTR OEMString + 8, ecx
  mov BYTE PTR OEMString + 12, 0
 }

 cout << "This CPU's OEM String is:"
   << OEMString
   << endl;

 _asm
 {
  mov eax, 1
  cpuid
  mov iEAXValue, eax
  mov iEBXValue, ebx
  mov iECXValue, ecx
  mov iEDXValue, edx
 }

 if(iEDXValue & 0x800000)
  cout << "This is MMX CPU"
    << endl;

 int iCPUFamily = (0xf00 & iEAXValue) >> 8;
 
 cout << "CPU Family is:"
   << iCPUFamily
   << endl;

 _asm
 {
  mov eax, 2
  cpuid
 }

 return 0;
}

原创粉丝点击