Hugh McMaster : reg: Only prompt the user to overwrite registry data if the given key already exists and [/f] is not supplied.

Alexandre Julliard julliard at winehq.org
Mon May 3 16:37:05 CDT 2021


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

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Mon May  3 23:20:37 2021 +1000

reg: Only prompt the user to overwrite registry data if the given key already exists and [/f] is not supplied.

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

---

 programs/reg/add.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/programs/reg/add.c b/programs/reg/add.c
index 258e3e8cb25..9aaa3fc1acc 100644
--- a/programs/reg/add.c
+++ b/programs/reg/add.c
@@ -154,18 +154,18 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
                    WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
 {
     HKEY hkey;
-    DWORD data_type, data_size;
+    DWORD dispos, data_type, data_size;
     BYTE *reg_data = NULL;
     LONG rc;
 
     if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE,
-                        KEY_READ|KEY_WRITE, NULL, &hkey, NULL))
+                        KEY_READ|KEY_WRITE, NULL, &hkey, &dispos))
     {
         output_message(STRING_ACCESS_DENIED);
         return 1;
     }
 
-    if (!force)
+    if (!force && dispos == REG_OPENED_EXISTING_KEY)
     {
         if (RegQueryValueExW(hkey, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
         {




More information about the wine-cvs mailing list