https://git.reactos.org/?p=reactos.git;a=commitdiff;h=18d15bcc8b3a61106693c…
commit 18d15bcc8b3a61106693c3d45d5ae33693ffe05a
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Thu Jul 1 00:08:33 2021 +0200
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Sun Sep 5 20:18:23 2021 +0300
[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.
---
base/applications/drwtsn32/main.cpp | 12 ++++--------
base/applications/mspaint/registry.cpp | 5 +----
base/applications/rapps/misc.cpp | 3 ---
3 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/base/applications/drwtsn32/main.cpp b/base/applications/drwtsn32/main.cpp
index 0c9d5664ce7..f49346ec16a 100644
--- a/base/applications/drwtsn32/main.cpp
+++ b/base/applications/drwtsn32/main.cpp
@@ -170,17 +170,13 @@ std::wstring Settings_GetOutputPath(void)
{
WCHAR Buffer[MAX_PATH] = L"";
ULONG BufferSize = _countof(Buffer);
- BOOL UseDefaultPath = FALSE;
+ BOOL UseDefaultPath = TRUE;
CRegKey key;
- if (key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\ReactOS\\Crash Reporter",
KEY_READ) != ERROR_SUCCESS)
- {
- UseDefaultPath = TRUE;
- }
-
- if (key.QueryStringValue(L"Dump Directory", Buffer, &BufferSize) !=
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 (UseDefaultPath)
diff --git a/base/applications/mspaint/registry.cpp
b/base/applications/mspaint/registry.cpp
index 369d8eaf45c..70361132c0a 100644
--- a/base/applications/mspaint/registry.cpp
+++ b/base/applications/mspaint/registry.cpp
@@ -19,10 +19,7 @@ static DWORD ReadDWORD(CRegKey &key, LPCTSTR lpName, DWORD
&dwValue, BOOL bCheck
{
DWORD dwPrev = dwValue;
- if (key.QueryDWORDValue(lpName, dwValue) != ERROR_SUCCESS)
- dwValue = dwPrev;
-
- if (bCheckForDef && dwValue == 0)
+ if (key.QueryDWORDValue(lpName, dwValue) != ERROR_SUCCESS || (bCheckForDef &&
dwValue == 0))
dwValue = dwPrev;
return dwPrev;
diff --git a/base/applications/rapps/misc.cpp b/base/applications/rapps/misc.cpp
index 8f1310d2320..e8418869a21 100644
--- a/base/applications/rapps/misc.cpp
+++ b/base/applications/rapps/misc.cpp
@@ -233,8 +233,6 @@ VOID InitLogs()
{
hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
}
-
- key.Close();
}
@@ -302,7 +300,6 @@ BOOL GetInstalledVersion_WowUser(ATL::CStringW* szVersionResult,
bHasSucceded = TRUE;
szVersion.ReleaseBuffer();
}
- key.Close();
return bHasSucceded;
}