https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4900dd3d87531c6ae411d…
commit 4900dd3d87531c6ae411dad376188cb9e1b229de
Author: Marcus Boillat <marcus.boillat(a)outlook.com>
AuthorDate: Tue May 24 11:20:52 2022 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue May 24 12:20:52 2022 +0300
[RAPPS] Improve localized display of installation date (#4498)
Parse InstallDate registry key in "YYYYMMDD" format. CORE-17422
Signed-off-by: Marcus Boillat <marcus.boillat(a)gmail.com>
Reviewed-by: Mark Jansen <mark.jansen(a)reactos.org>
Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
Reviewed-by: Stanislav Motylkov <x86corez(a)gmail.com>
---
base/applications/rapps/installed.cpp | 49 ++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/base/applications/rapps/installed.cpp
b/base/applications/rapps/installed.cpp
index 3528c2c3aaa..7162f471b50 100644
--- a/base/applications/rapps/installed.cpp
+++ b/base/applications/rapps/installed.cpp
@@ -45,30 +45,43 @@ void CInstalledApplicationInfo::EnsureDetailsLoaded()
GetApplicationRegString(L"Contact", szContact);
GetApplicationRegString(L"URLUpdateInfo", szURLUpdateInfo);
GetApplicationRegString(L"URLInfoAbout", szURLInfoAbout);
- if (GetApplicationRegString(L"InstallDate", szInstallDate) == FALSE)
+
+ DWORD dwInstallTimeStamp;
+ SYSTEMTIME InstallLocalTime;
+ if (GetApplicationRegString(L"InstallDate", szInstallDate))
{
- // It might be a DWORD (Unix timestamp). try again.
- DWORD dwInstallTimeStamp;
- if (GetApplicationRegDword(L"InstallDate",
&dwInstallTimeStamp))
+ 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)
{
- FILETIME InstallFileTime;
- SYSTEMTIME InstallSystemTime, InstallLocalTime;
+ 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;
+ SYSTEMTIME InstallSystemTime;
- UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
- FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
+ UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
+ FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
- // convert to localtime
- SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime,
&InstallLocalTime);
+ // convert to localtime
+ SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime,
&InstallLocalTime);
+ }
- // convert to readable date string
- int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0,
&InstallLocalTime, NULL, 0, 0);
+ // convert to readable date string
+ int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime,
NULL, 0, 0);
+
+ GetDateFormatW(
+ LOCALE_USER_DEFAULT, // use default locale for current user
+ 0, &InstallLocalTime, NULL, szInstallDate.GetBuffer(cchTimeStrLen),
cchTimeStrLen);
+ szInstallDate.ReleaseBuffer();
- GetDateFormatW(
- LOCALE_USER_DEFAULT, // use default locale for current user
- 0, &InstallLocalTime, NULL,
szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
- szInstallDate.ReleaseBuffer();
- }
- }
GetApplicationRegString(L"InstallLocation", szInstallLocation);
GetApplicationRegString(L"InstallSource", szInstallSource);
DWORD dwWindowsInstaller = 0;