From 76c0050d606c2d2bfe0509b4fb90aa4fa625c655 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 17 Nov 2024 23:27:19 +0100 Subject: [PATCH] GUI: Small improvement in executable version check. --- gui/Process/ExecutableHelper.cs | 8 ++++++-- gui/Utilities/VersionInfo.cs | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gui/Process/ExecutableHelper.cs b/gui/Process/ExecutableHelper.cs index 41facaa..400ccbe 100644 --- a/gui/Process/ExecutableHelper.cs +++ b/gui/Process/ExecutableHelper.cs @@ -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); + } } } diff --git a/gui/Utilities/VersionInfo.cs b/gui/Utilities/VersionInfo.cs index f000165..5b8afd9 100644 --- a/gui/Utilities/VersionInfo.cs +++ b/gui/Utilities/VersionInfo.cs @@ -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")); } // =============================================================================