Create cpu_speed.c

This commit is contained in:
janbodnar 2016-01-31 13:58:16 +01:00
parent 441e316f0e
commit 20dc63bb54

30
system/cpu_speed.c Normal file
View File

@ -0,0 +1,30 @@
#include <windows.h>
#include <wchar.h>
int wmain(void) {
DWORD BufSize = MAX_PATH;
DWORD mhz = MAX_PATH;
HKEY key;
long r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &key);
if (r != ERROR_SUCCESS) {
wprintf(L"RegOpenKeyExW() failed %ld", GetLastError());
return 1;
}
r = RegQueryValueExW(key, L"~MHz", NULL, NULL, (LPBYTE) &mhz, &BufSize);
if (r != ERROR_SUCCESS) {
wprintf(L"RegQueryValueExW() failed %ld", GetLastError());
return 1;
}
wprintf(L"CPU speed: %lu MHz\n", mhz);
return 0;
}