[REACTOS] Refactor CRegKey usage (#3779)

- [MSPAINT] ReadDWORD(): Improve 'dwValue' handling
Addendum to 3185db7 (r72158).

- [DRWTSN32] Settings_GetOutputPath(): Fix 'key' handling
Addendum to 1d10606.

- [RAPPS] Remove 2 superfluous 'CRegKey::Close()' calls
Follow-up to 42e111f.
This commit is contained in:
Serge Gautherie 2021-07-01 00:08:33 +02:00 committed by Stanislav Motylkov
parent a0bf7a05cc
commit 18d15bcc8b
No known key found for this signature in database
GPG key ID: AFE513258CBA9E92
3 changed files with 5 additions and 15 deletions

View file

@ -170,17 +170,13 @@ std::wstring Settings_GetOutputPath(void)
{ {
WCHAR Buffer[MAX_PATH] = L""; WCHAR Buffer[MAX_PATH] = L"";
ULONG BufferSize = _countof(Buffer); ULONG BufferSize = _countof(Buffer);
BOOL UseDefaultPath = FALSE; BOOL UseDefaultPath = TRUE;
CRegKey key; CRegKey key;
if (key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\ReactOS\\Crash Reporter", KEY_READ) != ERROR_SUCCESS) if (key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\ReactOS\\Crash Reporter", KEY_READ) == ERROR_SUCCESS &&
key.QueryStringValue(L"Dump Directory", Buffer, &BufferSize) == ERROR_SUCCESS)
{ {
UseDefaultPath = TRUE; UseDefaultPath = FALSE;
}
if (key.QueryStringValue(L"Dump Directory", Buffer, &BufferSize) != ERROR_SUCCESS)
{
UseDefaultPath = TRUE;
} }
if (UseDefaultPath) if (UseDefaultPath)

View file

@ -19,10 +19,7 @@ static DWORD ReadDWORD(CRegKey &key, LPCTSTR lpName, DWORD &dwValue, BOOL bCheck
{ {
DWORD dwPrev = dwValue; DWORD dwPrev = dwValue;
if (key.QueryDWORDValue(lpName, dwValue) != ERROR_SUCCESS) if (key.QueryDWORDValue(lpName, dwValue) != ERROR_SUCCESS || (bCheckForDef && dwValue == 0))
dwValue = dwPrev;
if (bCheckForDef && dwValue == 0)
dwValue = dwPrev; dwValue = dwPrev;
return dwPrev; return dwPrev;

View file

@ -233,8 +233,6 @@ VOID InitLogs()
{ {
hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager"); hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
} }
key.Close();
} }
@ -302,7 +300,6 @@ BOOL GetInstalledVersion_WowUser(ATL::CStringW* szVersionResult,
bHasSucceded = TRUE; bHasSucceded = TRUE;
szVersion.ReleaseBuffer(); szVersion.ReleaseBuffer();
} }
key.Close();
return bHasSucceded; return bHasSucceded;
} }