From f5a7d899551bb2deddc3ce84eeae4d5f0b6764d3 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Mon, 25 May 2026 22:21:20 +0200 Subject: [PATCH] [RAPPS] Use the package name if REGNAME is not set when uninstalling (#9058) --- base/applications/rapps/appdb.cpp | 11 ++++++++--- base/applications/rapps/appinfo.cpp | 12 ++++++++++-- base/applications/rapps/geninst.cpp | 2 +- base/applications/rapps/include/appinfo.h | 2 +- base/applications/rapps/unattended.cpp | 10 +++------- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/base/applications/rapps/appdb.cpp b/base/applications/rapps/appdb.cpp index b931ded745b..ae35855154a 100644 --- a/base/applications/rapps/appdb.cpp +++ b/base/applications/rapps/appdb.cpp @@ -50,9 +50,14 @@ public: UNINSTALL_SUBKEY, KEY_WOW64_32KEY); } - HKEY GetNext(REGSAM &RegSam) + HKEY Get(REGSAM &RegSam) { - return m_Index < m_Count ? GetRootKeyInfo(m_Index++, RegSam) : NULL; + return m_Index < m_Count ? GetRootKeyInfo(m_Index, RegSam) : NULL; + } + + void Next() + { + m_Index++; } UINT GetKeyIndex() const @@ -235,7 +240,7 @@ CAppDB::EnumerateRegistry(CAtlList *List, LPCWSTR SearchOnly) ATLASSERT(List || SearchOnly); REGSAM wowsam; HKEY hRootKey; - for (CEnumInstalledRootKey RootEnum; (hRootKey = RootEnum.GetNext(wowsam)) != NULL;) + for (CEnumInstalledRootKey RootEnum; (hRootKey = RootEnum.Get(wowsam)) != NULL; RootEnum.Next()) { CRegKey hKey; if (hKey.Open(hRootKey, UNINSTALL_SUBKEY, KEY_READ | wowsam) != ERROR_SUCCESS) diff --git a/base/applications/rapps/appinfo.cpp b/base/applications/rapps/appinfo.cpp index 5766d9a9178..05b0549319b 100644 --- a/base/applications/rapps/appinfo.cpp +++ b/base/applications/rapps/appinfo.cpp @@ -121,11 +121,19 @@ CompareVersion(const CStringW &left, const CStringW &right) } bool -CAvailableApplicationInfo::IsInstalled() const +CAvailableApplicationInfo::IsInstalled(CStringW *pOutKeyName) const { + LPCWSTR pszKeyName = NULL; CStringW szRegName; m_Parser->GetString(DB_REGNAME, szRegName); - return ::GetInstalledVersion(NULL, szRegName) || ::GetInstalledVersion(NULL, szDisplayName); + if (::GetInstalledVersion(NULL, szRegName)) + pszKeyName = szRegName.GetString(); + else if (::GetInstalledVersion(NULL, szDisplayName)) + pszKeyName = szDisplayName.GetString(); + + if (pszKeyName && pOutKeyName) + *pOutKeyName = pszKeyName; + return pszKeyName != NULL; } VOID diff --git a/base/applications/rapps/geninst.cpp b/base/applications/rapps/geninst.cpp index b5caf9b3aa7..e6b649043e2 100644 --- a/base/applications/rapps/geninst.cpp +++ b/base/applications/rapps/geninst.cpp @@ -805,7 +805,7 @@ UninstallThread(LPVOID Parameter) if (!DeleteFile(str)) { err = GetLastError(); - if (err != ERROR_FILE_NOT_FOUND) + if (err != ERROR_FILE_NOT_FOUND && err != ERROR_PATH_NOT_FOUND) { return ErrorBox(err); } diff --git a/base/applications/rapps/include/appinfo.h b/base/applications/rapps/include/appinfo.h index 019533e7279..0b1bb812669 100644 --- a/base/applications/rapps/include/appinfo.h +++ b/base/applications/rapps/include/appinfo.h @@ -180,7 +180,7 @@ class CAvailableApplicationInfo : public CAppInfo bool IsCompatible() const; bool - IsInstalled() const; + IsInstalled(CStringW *pOutKeyName = NULL) const; virtual BOOL Valid() const override; diff --git a/base/applications/rapps/unattended.cpp b/base/applications/rapps/unattended.cpp index 0efd9b12c7b..156e71a253a 100644 --- a/base/applications/rapps/unattended.cpp +++ b/base/applications/rapps/unattended.cpp @@ -166,14 +166,10 @@ HandleUninstallCommand(CAppDB &db, UINT argcLeft, LPWSTR *argvLeft) if (!pInfo) { CAvailableApplicationInfo *p = db.FindAvailableByPackageName(name); - if (p) + if (p && p->IsInstalled(&buf)) { - CConfigParser *cp = p->GetConfigParser(); - if (cp && cp->GetString(DB_REGNAME, buf) && !buf.IsEmpty()) - { - name = buf.GetString(); - byregkeyname = TRUE; - } + name = buf.GetString(); + byregkeyname = TRUE; } } }