老實講你真的要準確的話得去看I和A兩家CPU公佈的資料裡面有很多可以參考的
ex:
http://www.intel.com/content/www/us...ction-note.html
不然土法煉鋼像這樣的寫法:
void GetProcessorSpeed()
{
double dCPUSpeedMHz = 0.0;
wchar_t sCPUSpeedMHz[1024];
LARGE_INTEGER qwWait, qwStart, qwCurrent;
QueryPerformanceCounter(&qwStart);
QueryPerformanceFrequency(&qwWait);
sCPUSpeedMHz[0] = 0;
qwWait.QuadPart >>= 5;
unsigned __int64 Start = __rdtsc();
do{
QueryPerformanceCounter(&qwCurrent);
}while(qwCurrent.QuadPart - qwStart.QuadPart < qwWait.QuadPart);
dCPUSpeedMHz = ((__rdtsc() - Start) << 5) / 1000000.0;
swprintf_s(sCPUSpeedMHz, 1024, _T("%f"), dCPUSpeedMHz);
MessageBox(sCPUSpeedMHz, _T("CPU MHz"), MB_OK);
}
你得到的永遠不會是正確的頻率,尤其是現在的CPU都會自動變速...