https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b62948ef774538fb5066e88c3b92ce2010bd842c

commit b62948ef774538fb5066e88c3b92ce2010bd842c
Author:     Oleg Dubinskiy <[email protected]>
AuthorDate: Wed Sep 16 17:54:20 2020 +0300
Commit:     Mark Jansen <[email protected]>
CommitDate: Sun Sep 20 19:23:06 2020 +0200

    [RAPPS] Use `RegDeleteKeyExW` for deleting the apps strings from registry 
only if it is available in advapi32
    Otherwise, use `RegDeleteKeyW` instead, on Windows versions whose don't 
have the Ex function (XP SP3 x32, Server 2003 SP0 and earlier).
    It will fix regression with Rapps startup there, due to that missing 
function.
    CORE-17264
---
 base/applications/rapps/installed.cpp | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/base/applications/rapps/installed.cpp 
b/base/applications/rapps/installed.cpp
index 4179334a60a..5296c3fc6ae 100644
--- a/base/applications/rapps/installed.cpp
+++ b/base/applications/rapps/installed.cpp
@@ -141,16 +141,34 @@ BOOL CInstalledApplicationInfo::UninstallApplication(BOOL 
bModify)
     return StartProcess(bModify ? szModifyPath : szUninstallString, TRUE);
 }
 
+typedef LSTATUS (WINAPI *RegDeleteKeyExWProc)(HKEY, LPCWSTR, REGSAM, DWORD);
+
 LSTATUS CInstalledApplicationInfo::RemoveFromRegistry()
 {
     ATL::CStringW szFullName = 
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + szKeyName;
+    HMODULE hMod = GetModuleHandleW(L"advapi32.dll");
+    RegDeleteKeyExWProc pRegDeleteKeyExW;
 
-    // TODO: if there are subkeys inside, simply RegDeleteKeyExW will fail
+    // TODO: if there are subkeys inside, simply RegDeleteKeyExW
+    // (or RegDeleteKeyW on Server 2003 SP0 and earlier) will fail
     // we don't have RegDeleteTree for ReactOS now. (It's a WinVista API)
     // write a function to delete all subkeys recursively to solve this
     // or consider letting ReactOS having this API
 
-    return RegDeleteKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, 
szFullName, WowKey, 0);
+    /* Load RegDeleteKeyExW from advapi32.dll if available */
+    if (hMod)
+    {
+        pRegDeleteKeyExW = (RegDeleteKeyExWProc)GetProcAddress(hMod, 
"RegDeleteKeyExW");
+
+        if (pRegDeleteKeyExW)
+        {
+            /* Return it */
+            return pRegDeleteKeyExW(IsUserKey ? HKEY_CURRENT_USER : 
HKEY_LOCAL_MACHINE, szFullName, WowKey, 0);
+        }
+    }
+
+    /* Otherwise, return non-Ex function */
+    return RegDeleteKeyW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, 
szFullName);
 }
 
 BOOL CInstalledApps::Enum(INT EnumType, APPENUMPROC lpEnumProc, PVOID param)

Reply via email to