标签:oca hardware handle str reg hand desc 入口 word
1 // 获得cpu主频.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include <windows.h> 6 #include <iostream> 7 8 using namespace std; 9 10 DWORD CPUClockMHz(); 11 12 int main() 13 { 14 DWORD CPUMHz; 15 CPUMHz = CPUClockMHz(); 16 17 cout << CPUMHz << endl; 18 19 return 0; 20 } 21 22 DWORD CPUClockMHz() 23 { 24 HKEY KeyHandle; 25 DWORD CPUMHz; 26 DWORD ReturnLength = sizeof(DWORD); 27 DWORD Type = REG_DWORD; 28 RegOpenKey(HKEY_LOCAL_MACHINE, 29 L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &KeyHandle); 30 RegQueryValueEx(KeyHandle, L"~MHz", NULL, &Type, (PBYTE)&CPUMHz, &ReturnLength); 31 RegCloseKey(KeyHandle); 32 return CPUMHz; 33 }
标签:oca hardware handle str reg hand desc 入口 word
原文地址:http://www.cnblogs.com/1228073191Blog/p/7565061.html