mov eax,01h ;eax =1返回的是feature flag http://www.intel.com/design/Pentium4/manuals/24547012.pdf page 320 Feature flags returned in EDXeax=03h ;return CPU serial number __asm{ mov eax,03h xor ecx,ecx xor edx,edx cpuid mov s1,edx mov s2,ecx } EAX Researved EBX Researved ECX Bits00-31 of 96 bit processor serial number(Available in Pentium 3 only) EDX Bits32-63 of 96 bit processor serial number(Available in Pentium 3 only)
什么叫做读取cpu?
你可以看一下这里
http://www.vccode.com
在硬件信息下找CAMEL - CPU Identifier Class
mov eax,01h
;eax =1返回的是feature flag
http://www.intel.com/design/Pentium4/manuals/24547012.pdf
page 320
Feature flags returned in EDXeax=03h ;return CPU serial number
__asm{ mov eax,03h
xor ecx,ecx
xor edx,edx
cpuid
mov s1,edx
mov s2,ecx
}
EAX Researved
EBX Researved
ECX Bits00-31 of 96 bit processor serial number(Available in Pentium 3 only)
EDX Bits32-63 of 96 bit processor serial number(Available in Pentium 3 only)
函数:取得CPU启动到现在运行的周期数
*/
_int64 Count(void)
{
_asm
{
_emit 0x0F
_emit 0x31
}
}
/*
函数:取得CPU信息
*/
void CSystemInfo::GetCpu()
{
CString m_strCpuInfo;
m_strCpuInfo.Empty();
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
}
m_strCpuInfo.Format("%s",OEMString);
_asm {
mov eax,1
cpuid
mov iEAXValue,eax
mov iEBXValue,ebx
mov iECXValue,ecx
mov iEDXValue,edx
}
if(iEDXValue&0x800000)
{
m_strCpuInfo+=" MMX Support";
}
else
{
m_strCpuInfo+=" No MMX Support";
}
int iCPUFamily=(0xf00 & iEAXValue)>>8;
CString m_family;
m_family.Format("%s%d","\r\n Family: ",iCPUFamily);
m_strCpuInfo+=m_family;
CString Frequency;
_int64 start=Count();
Sleep(1000);
_int64 stop=Count();
UINT cpuspeed = (UINT)((stop-start)/1000000);
Frequency.Format("%d MHZ",cpuspeed);
CString cpuinfo;
cpuinfo.Format("%s%s","频率: ",Frequency);
m_strCpuInfo+=cpuinfo;
strcpy(cpu,m_strCpuInfo);
}