missing reg key closing
This commit is contained in:
parent
0ff6488545
commit
bbed99ba8c
1 changed files with 18 additions and 8 deletions
|
|
@ -79,9 +79,12 @@ namespace tmr {
|
|||
LPBYTE dataContent = nullptr;
|
||||
DWORD dataLen;
|
||||
|
||||
status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0,
|
||||
KEY_QUERY_VALUE, &key);
|
||||
if(status != ERROR_SUCCESS) return CANT_OPEN_KEY;
|
||||
status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &key);
|
||||
|
||||
if(status != ERROR_SUCCESS) {
|
||||
status = RegCloseKey(key);
|
||||
return CANT_OPEN_KEY;
|
||||
}
|
||||
|
||||
status = RegQueryInfoKey(
|
||||
key, // key handle
|
||||
|
|
@ -96,7 +99,10 @@ namespace tmr {
|
|||
&longestDataSize, // longest value data
|
||||
NULL, // security descriptor
|
||||
NULL); // last write time
|
||||
if(status != ERROR_SUCCESS) return CANT_RETRIEVE_KEY_INFO;
|
||||
if(status != ERROR_SUCCESS) {
|
||||
status = RegCloseKey(key);
|
||||
return CANT_RETRIEVE_KEY_INFO;
|
||||
}
|
||||
|
||||
dataLen = sizeof(REG_QWORD) * (longestDataSize);
|
||||
dataContent = (LPBYTE)malloc(dataLen);
|
||||
|
|
@ -113,7 +119,10 @@ namespace tmr {
|
|||
&dataLen
|
||||
);
|
||||
|
||||
if(status != ERROR_SUCCESS) return CANT_READ_DATA_FROM_VALUE;
|
||||
if(status != ERROR_SUCCESS) {
|
||||
RegCloseKey(key);
|
||||
return CANT_READ_DATA_FROM_VALUE;
|
||||
}
|
||||
|
||||
if (CSTR_EQUAL == CompareStringEx(
|
||||
LOCALE_NAME_INVARIANT,
|
||||
|
|
@ -125,14 +134,15 @@ namespace tmr {
|
|||
NULL,
|
||||
NULL,
|
||||
0
|
||||
)
|
||||
) {
|
||||
))
|
||||
{
|
||||
LPDWORD PMHz = (LPDWORD)dataContent;
|
||||
DWORD MHz = *PMHz;
|
||||
free(dataContent);
|
||||
return MHz * 1000000;
|
||||
}
|
||||
}
|
||||
status = RegCloseKey(key);
|
||||
return CANT_READ_DATA_FROM_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue