16,472
社区成员
发帖
与我相关
我的任务
分享
int main()
{
SYSTEM_INFO SysInfo;
GetSystemInfo(&SysInfo);
cout<<SysInfo.dwNumberOfProcessors<<endl;
cout<<SysInfo.dwProcessorType<<endl;
cout<<SysInfo.dwActiveProcessorMask<<endl;
cout<<SysInfo.dwAllocationGranularity<<endl;
cout<<SysInfo.dwOemId<<endl;
cout<<SysInfo.dwPageSize<<endl;
cout<<SysInfo.lpMaximumApplicationAddress<<endl;
cout<<SysInfo.lpMinimumApplicationAddress<<endl;
cout<<SysInfo.wProcessorArchitecture <<endl;
cout<<SysInfo.wProcessorLevel <<endl;
cout<<SysInfo.wProcessorRevision<<endl;
cout<<SysInfo.wReserved<<endl;
return 0;
}
void GetCPUInfo(int cpuinfo[4], int tp)
{
__asm
{
mov eax, tp
cpuid
mov edi, cpuinfo
mov dword ptr [edi], eax
mov dword ptr [edi+4], ebx
mov dword ptr [edi+8], ecx
mov dword ptr [edi+12], edx
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char cpuName[64] = {0};
int (*pTmp)[4] = (int(*)[4])cpuName;
GetCPUInfo(*pTmp++, 0x80000002);
GetCPUInfo(*pTmp++, 0x80000003);
GetCPUInfo(*pTmp++, 0x80000004);
printf("%s\n", cpuName);
return 0;
}