[RAPPS] Improve localized display of installation date (#4498)

Parse InstallDate registry key in "YYYYMMDD" format. CORE-17422

Signed-off-by: Marcus Boillat <marcus.boillat@gmail.com>
Reviewed-by: Mark Jansen <mark.jansen@reactos.org>
Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Reviewed-by: Stanislav Motylkov <x86corez@gmail.com>
This commit is contained in:
Marcus Boillat 2022-05-24 11:20:52 +02:00 committed by GitHub
parent 505ac6565a
commit 4900dd3d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,20 +45,34 @@ void CInstalledApplicationInfo::EnsureDetailsLoaded()
GetApplicationRegString(L"Contact", szContact); GetApplicationRegString(L"Contact", szContact);
GetApplicationRegString(L"URLUpdateInfo", szURLUpdateInfo); GetApplicationRegString(L"URLUpdateInfo", szURLUpdateInfo);
GetApplicationRegString(L"URLInfoAbout", szURLInfoAbout); GetApplicationRegString(L"URLInfoAbout", szURLInfoAbout);
if (GetApplicationRegString(L"InstallDate", szInstallDate) == FALSE)
{
// It might be a DWORD (Unix timestamp). try again.
DWORD dwInstallTimeStamp; DWORD dwInstallTimeStamp;
if (GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp)) SYSTEMTIME InstallLocalTime;
if (GetApplicationRegString(L"InstallDate", szInstallDate))
{
ZeroMemory(&InstallLocalTime, sizeof(InstallLocalTime));
// Check if we have 8 characters to parse the datetime.
// Maybe other formats exist as well?
szInstallDate = szInstallDate.Trim();
if (szInstallDate.GetLength() == 8)
{
InstallLocalTime.wYear = wcstol(szInstallDate.Left(4).GetString(), NULL, 10);
InstallLocalTime.wMonth = wcstol(szInstallDate.Mid(4, 2).GetString(), NULL, 10);
InstallLocalTime.wDay = wcstol(szInstallDate.Mid(6, 2).GetString(), NULL, 10);
}
}
// It might be a DWORD (Unix timestamp). try again.
else if (GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
{ {
FILETIME InstallFileTime; FILETIME InstallFileTime;
SYSTEMTIME InstallSystemTime, InstallLocalTime; SYSTEMTIME InstallSystemTime;
UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime); UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime); FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
// convert to localtime // convert to localtime
SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime); SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
}
// convert to readable date string // convert to readable date string
int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime, NULL, 0, 0); int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime, NULL, 0, 0);
@ -67,8 +81,7 @@ void CInstalledApplicationInfo::EnsureDetailsLoaded()
LOCALE_USER_DEFAULT, // use default locale for current user LOCALE_USER_DEFAULT, // use default locale for current user
0, &InstallLocalTime, NULL, szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen); 0, &InstallLocalTime, NULL, szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
szInstallDate.ReleaseBuffer(); szInstallDate.ReleaseBuffer();
}
}
GetApplicationRegString(L"InstallLocation", szInstallLocation); GetApplicationRegString(L"InstallLocation", szInstallLocation);
GetApplicationRegString(L"InstallSource", szInstallSource); GetApplicationRegString(L"InstallSource", szInstallSource);
DWORD dwWindowsInstaller = 0; DWORD dwWindowsInstaller = 0;