GUI: Small improvement in executable version check.

This commit is contained in:
LoRd_MuldeR 2024-11-17 23:27:19 +01:00
parent 08aaf69262
commit 76c0050d60
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
2 changed files with 11 additions and 6 deletions

View File

@ -6,7 +6,6 @@
using System;
using System.Diagnostics;
using System.IO;
using com.muldersoft.slunkcrypt.gui.utils;
namespace com.muldersoft.slunkcrypt.gui.process
@ -87,7 +86,7 @@ namespace com.muldersoft.slunkcrypt.gui.process
string.Equals(fileVersion.CompanyName, "Muldersoft", StringComparison.OrdinalIgnoreCase) &&
(fileVersion.FileMajorPart == appVersion.Major) && (fileVersion.FileMinorPart == appVersion.Minor))
{
success = (fileVersion.FilePrivatePart >= appVersion.Revision);
success = ToVersion64(fileVersion.FileBuildPart, fileVersion.FilePrivatePart) >= ToVersion64(appVersion.Build, appVersion.Revision);
}
}
finally
@ -101,5 +100,10 @@ namespace com.muldersoft.slunkcrypt.gui.process
catch { }
return success;
}
static ulong ToVersion64(int upper, int lower)
{
return (Convert.ToUInt64(upper) << 32) | Convert.ToUInt64(lower);
}
}
}

View File

@ -23,10 +23,11 @@ namespace com.muldersoft.slunkcrypt.gui.utils
public static new string ToString()
{
Version version = m_version.Value;
return string.Format(
(version.Revision > 0) ? "Version {0:D}.{1:D}.{2:D}, built on {3}" : "Version {0:D}.{1:D}, built on {3}",
version.Major, version.Minor, version.Revision, BuildDate.ToString("yyyy-MM-dd"));
Version value = Version;
string versionString = string.Format(
((value.Revision > 0) || (value.Build > 0)) ? ((value.Build > 0) ? "{0:D}.{1:D}.{2:D}.{3:D}" : "{0:D}.{1:D}.{3:D}") : "{0:D}.{1:D}",
value.Major, value.Minor, value.Build, value.Revision);
return string.Format("Version {0}, built on {1}", versionString, BuildDate.ToString("yyyy-MM-dd"));
}
// =============================================================================