|
如下代码可以去获取CPU的主频
int CpuFreq;
CString strCpuFreq;
SYSTEM_INFO sys_info;
GetSystemInfo(&sys_info);
PROCESSOR_INFO pro;
DWORD count;
KernelIoControl(IOCTL_PROCESSOR_INFORMATION, NULL, 0, &pro, sizeof(PROCESSOR_INFO), &count);
lstrcpy(szTemp, pro.szVendor);
if(pro.szVendor[0] != NULL && (pro.szProcessCore[0] != NULL || pro.szProcessorName[0] != NULL))
{
lstrcat(szTemp, TEXT(", "));
}
lstrcat(szTemp, pro.szProcessCore);
if(pro.szProcessCore[0] != NULL && pro.szProcessorName[0] != NULL)
{
lstrcat(szTemp, TEXT("-"));
}
lstrcat(szTemp, pro.szProcessorName);
CpuFreq=pro.dwClockSpeed/1000000;
strCpuFreq.Format(_T("%d"),CpuFreq);
lstrcat(szTemp, TEXT("("));
lstrcat(szTemp, strCpuFreq);
lstrcat(szTemp, TEXT("MHZ"));
lstrcat(szTemp, TEXT(")"));
SetDlgItemText(IDC_STATIC_CPUTYPE, szTemp); |
|