From 60593e8bfdaa748bd006f364a1f134e79066f6a5 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 28 Feb 2016 03:36:07 +0100
Subject: setupapi: DelReg should recursively delete registry keys.

---
 dlls/setupapi/install.c       | 7 ++++++-
 dlls/setupapi/tests/install.c | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c
index a8d38aa..2aefc16 100644
--- a/dlls/setupapi/install.c
+++ b/dlls/setupapi/install.c
@@ -302,6 +302,7 @@ static void delete_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
  */
 static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context, INT flags )
 {
+    static const WCHAR emptyW[] = {0};
     DWORD type, size;
 
     if (flags & (FLG_ADDREG_DELREG_BIT | FLG_ADDREG_DELVAL))  /* deletion */
@@ -320,7 +321,11 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
             }
             else RegDeleteValueW( hkey, value );
         }
-        else NtDeleteKey( hkey );
+        else
+        {
+            RegDeleteTreeW( hkey, NULL );
+            RegDeleteKeyW( hkey, emptyW );
+        }
         return TRUE;
     }
 
diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c
index d12d683..e09ac8e 100644
--- a/dlls/setupapi/tests/install.c
+++ b/dlls/setupapi/tests/install.c
@@ -174,7 +174,6 @@ static void test_registry(void)
 
     /* Check if the registry key is recursively deleted */
     res = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest", &key);
-    todo_wine
     ok(res == ERROR_FILE_NOT_FOUND, "Didn't expect the registry key to exist\n");
     /* Just in case */
     if (res == ERROR_SUCCESS)
-- 
2.7.1