mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2026-07-14 10:12:48 -04:00
Create cpu_speed.c
This commit is contained in:
parent
441e316f0e
commit
20dc63bb54
30
system/cpu_speed.c
Normal file
30
system/cpu_speed.c
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user