mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Update cpu_speed.c
This commit is contained in:
parent
24f2532913
commit
200f998402
@ -8,23 +8,31 @@ int wmain(void) {
|
|||||||
HKEY key;
|
HKEY key;
|
||||||
|
|
||||||
long r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
long r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &key);
|
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &key);
|
||||||
|
|
||||||
if (r != ERROR_SUCCESS) {
|
if (r != ERROR_SUCCESS) {
|
||||||
|
|
||||||
wprintf(L"RegOpenKeyExW() failed %ld", GetLastError());
|
wprintf(L"RegOpenKeyExW() failed %ld", GetLastError());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = RegQueryValueExW(key, L"~MHz", NULL, NULL, (LPBYTE) &mhz, &BufSize);
|
r = RegQueryValueExW(key, L"~MHz", NULL, NULL, (LPBYTE) &mhz, &BufSize);
|
||||||
|
|
||||||
if (r != ERROR_SUCCESS) {
|
if (r != ERROR_SUCCESS) {
|
||||||
|
|
||||||
wprintf(L"RegQueryValueExW() failed %ld", GetLastError());
|
wprintf(L"RegQueryValueExW() failed %ld", GetLastError());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintf(L"CPU speed: %lu MHz\n", mhz);
|
wprintf(L"CPU speed: %lu MHz\n", mhz);
|
||||||
|
|
||||||
|
r = RegCloseKey(key);
|
||||||
|
|
||||||
|
if (r != ERROR_SUCCESS) {
|
||||||
|
|
||||||
|
wprintf(L"Failed to close registry handle %ld", GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user