[RAPPS] Use the package name if REGNAME is not set when uninstalling (#9058)

This commit is contained in:
Whindmar Saksit
2026-05-25 22:21:20 +02:00
committed by GitHub
parent 4a96f375a0
commit f5a7d89955
5 changed files with 23 additions and 14 deletions

View File

@@ -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<CAppInfo *> *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)

View File

@@ -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

View File

@@ -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);
}

View File

@@ -180,7 +180,7 @@ class CAvailableApplicationInfo : public CAppInfo
bool
IsCompatible() const;
bool
IsInstalled() const;
IsInstalled(CStringW *pOutKeyName = NULL) const;
virtual BOOL
Valid() const override;

View File

@@ -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;
}
}
}