Hugh McMaster : regedit: Simplify the detection of existing registry values.

Alexandre Julliard julliard at winehq.org
Mon May 21 17:15:10 CDT 2018


Module: wine
Branch: master
Commit: b24ee836bd8fef2cc960312d2b2b565c407b0907
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b24ee836bd8fef2cc960312d2b2b565c407b0907

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Mon May 21 13:34:57 2018 +0000

regedit: Simplify the detection of existing registry values.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/regedit/edit.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index 4307766..59221f4 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -184,12 +184,9 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara
     return FALSE;
 }
 
-static BOOL check_value(HWND hwnd, HKEY hKey, LPCWSTR valueName)
+static BOOL value_exists(HWND hwnd, HKEY hKey, const WCHAR *value_name)
 {
-    WCHAR empty = 0;
-    LONG lRet = RegQueryValueExW(hKey, valueName ? valueName : &empty, 0, NULL, 0, NULL);
-    if(lRet != ERROR_SUCCESS) return FALSE;
-    return TRUE;
+    return !RegQueryValueExW(hKey, value_name, NULL, NULL, NULL, NULL);
 }
 
 static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType, LONG *len)
@@ -508,8 +505,8 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
         error_code_messagebox(hwnd, IDS_RENAME_VALUE_FAILED);
 	return FALSE;
     }
-    /* check if the value already exists */
-    if (check_value(hwnd, hKey, newName)) {
+
+    if (value_exists(hwnd, hKey, newName)) {
         error_code_messagebox(hwnd, IDS_VALUE_EXISTS, oldName);
         goto done;
     }




More information about the wine-cvs mailing list