[RAPPS] Automatically generate installer/uninstaller for downloaded zip/cab files (#6652)

With a single database line added to applications distributed as zip/cab allows rapps.exe to act as an installer that automatically extracts the files and creates a startmenu shortcut. It can also uninstall the extracted files (and optionally other files and registry entries created by the application).
This commit is contained in:
Whindmar Saksit 2024-05-08 23:58:54 +02:00 committed by GitHub
parent ad8392602e
commit 57b775ef6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 1638 additions and 137 deletions

View file

@ -116,7 +116,7 @@ VOID
CAvailableApplicationInfo::InsertVersionInfo(CAppRichEdit *RichEdit)
{
CStringW szRegName;
m_Parser->GetString(L"RegName", szRegName);
m_Parser->GetString(DB_REGNAME, szRegName);
BOOL bIsInstalled = ::GetInstalledVersion(NULL, szRegName) || ::GetInstalledVersion(NULL, szDisplayName);
if (bIsInstalled)
@ -131,11 +131,14 @@ CAvailableApplicationInfo::InsertVersionInfo(CAppRichEdit *RichEdit)
{
BOOL bHasUpdate = CompareVersion(szInstalledVersion, szDisplayVersion) < 0;
if (bHasUpdate)
{
RichEdit->LoadAndInsertText(IDS_STATUS_UPDATE_AVAILABLE, CFE_ITALIC);
RichEdit->LoadAndInsertText(IDS_AINFO_VERSION, szInstalledVersion, 0);
}
else
{
RichEdit->LoadAndInsertText(IDS_STATUS_INSTALLED, CFE_ITALIC);
RichEdit->LoadAndInsertText(IDS_AINFO_VERSION, szInstalledVersion, 0);
}
}
else
{
@ -364,8 +367,19 @@ CAvailableApplicationInfo::GetDisplayInfo(CStringW &License, CStringW &Size, CSt
UrlDownload = m_szUrlDownload;
}
InstallerType
CAvailableApplicationInfo::GetInstallerType() const
{
CStringW str;
m_Parser->GetString(DB_INSTALLER, str);
if (str.CompareNoCase(DB_GENINSTSECTION) == 0)
return INSTALLER_GENERATE;
else
return INSTALLER_UNKNOWN;
}
BOOL
CAvailableApplicationInfo::UninstallApplication(BOOL bModify)
CAvailableApplicationInfo::UninstallApplication(UninstallCommandFlags Flags)
{
ATLASSERT(FALSE && "Should not be called");
return FALSE;
@ -374,9 +388,8 @@ CAvailableApplicationInfo::UninstallApplication(BOOL bModify)
CInstalledApplicationInfo::CInstalledApplicationInfo(
HKEY Key,
const CStringW &KeyName,
AppsCategories Category,
int KeyIndex)
: CAppInfo(KeyName, Category), m_hKey(Key), iKeyIndex(KeyIndex)
AppsCategories Category, UINT KeyInfo)
: CAppInfo(KeyName, Category), m_hKey(Key), m_KeyInfo(KeyInfo)
{
if (GetApplicationRegString(L"DisplayName", szDisplayName))
{
@ -561,15 +574,51 @@ CInstalledApplicationInfo::GetDisplayInfo(CStringW &License, CStringW &Size, CSt
ATLASSERT(FALSE && "Should not be called");
}
BOOL
CInstalledApplicationInfo::UninstallApplication(BOOL bModify)
InstallerType
CInstalledApplicationInfo::GetInstallerType() const
{
CRegKey reg;
if (reg.Open(m_hKey, GENERATE_ARPSUBKEY, KEY_READ) == ERROR_SUCCESS)
{
return INSTALLER_GENERATE;
}
return INSTALLER_UNKNOWN;
}
BOOL
CInstalledApplicationInfo::UninstallApplication(UninstallCommandFlags Flags)
{
if (GetInstallerType() == INSTALLER_GENERATE)
{
return UninstallGenerated(*this, Flags);
}
BOOL bModify = Flags & UCF_MODIFY;
if (m_szUninstallString.IsEmpty())
{
RetrieveUninstallStrings();
}
BOOL bSuccess = StartProcess(bModify ? m_szModifyString : m_szUninstallString, TRUE);
CStringW cmd = bModify ? m_szModifyString : m_szUninstallString;
if ((Flags & (UCF_MODIFY | UCF_SILENT)) == UCF_SILENT)
{
DWORD msi = 0;
msi = GetApplicationRegDword(L"WindowsInstaller", &msi) && msi;
if (msi)
{
cmd += L" /qn";
}
else
{
CStringW silentcmd;
if (GetApplicationRegString(L"QuietUninstallString", silentcmd) && !silentcmd.IsEmpty())
{
cmd = silentcmd;
}
}
}
BOOL bSuccess = StartProcess(cmd, TRUE);
if (bSuccess && !bModify)
WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szDisplayName);