From 200f9984027862158d3fa068b54cae95b66b7d19 Mon Sep 17 00:00:00 2001 From: Jan Bodnar Date: Mon, 1 Feb 2016 12:14:00 +0100 Subject: [PATCH] Update cpu_speed.c --- system/cpu_speed.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/system/cpu_speed.c b/system/cpu_speed.c index 2d9553b..c43f0a2 100644 --- a/system/cpu_speed.c +++ b/system/cpu_speed.c @@ -8,23 +8,31 @@ int wmain(void) { HKEY key; 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) { - + wprintf(L"RegOpenKeyExW() failed %ld", GetLastError()); - return 1; + 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); + + r = RegCloseKey(key); + + if (r != ERROR_SUCCESS) { + + wprintf(L"Failed to close registry handle %ld", GetLastError()); + return 1; + } return 0; }