[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

@ -25,6 +25,20 @@ struct CSectionNames
};
static CSectionNames g_Names;
HRESULT
ReadIniValue(LPCWSTR File, LPCWSTR Section, LPCWSTR Name, CStringW &Output)
{
for (DWORD len = 256, ret;; len *= 2)
{
ret = GetPrivateProfileString(Section, Name, L"\n", Output.GetBuffer(len), len, File);
if (ret + 1 != len)
{
Output.ReleaseBuffer(ret);
return ret && Output[0] != L'\n' ? ret : HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
}
}
}
CConfigParser::CConfigParser(const CStringW &FilePath) : szConfigPath(FilePath)
{
CacheINI();
@ -166,3 +180,42 @@ CConfigParser::GetInt(const CStringW &KeyName, INT &iResult)
// we only care about values > 0
return (iResult > 0);
}
UINT
CConfigParser::GetSectionString(LPCWSTR Section, LPCWSTR Name, CStringW &Result)
{
HRESULT hr; // Return value; length of ini string or 0 on failure.
CStringW SecBuf;
WCHAR FullLoc[5], *NeutralLoc = FullLoc + 2;
GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE, FullLoc, _countof(FullLoc));
SecBuf.Format(L"%s.%s.%s", Section, FullLoc, CurrentArchitecture);
if ((hr = ReadIniValue(szConfigPath, SecBuf, Name, Result)) > 0)
return hr;
if (*NeutralLoc)
{
SecBuf.Format(L"%s.%s.%s", Section, NeutralLoc, CurrentArchitecture);
if ((hr = ReadIniValue(szConfigPath, SecBuf, Name, Result)) > 0)
return hr;
}
SecBuf.Format(L"%s.%s", Section, CurrentArchitecture);
if ((hr = ReadIniValue(szConfigPath, SecBuf, Name, Result)) > 0)
return hr;
SecBuf.Format(L"%s.%s", Section, FullLoc);
if ((hr = ReadIniValue(szConfigPath, SecBuf, Name, Result)) > 0)
return hr;
if (*NeutralLoc)
{
SecBuf.Format(L"%s.%s", Section, NeutralLoc);
if ((hr = ReadIniValue(szConfigPath, SecBuf, Name, Result)) > 0)
return hr;
}
if ((hr = ReadIniValue(szConfigPath, Section, Name, Result)) > 0)
return hr;
return 0;
}