commit e388537531320af000bbb634319e63184631bdd9 Author: Eugen Höglinger Date: Fri Oct 11 16:24:59 2024 +0200 Initialized diff --git a/.vs/VersionComparison/v17/.suo b/.vs/VersionComparison/v17/.suo new file mode 100644 index 0000000..e8750e3 Binary files /dev/null and b/.vs/VersionComparison/v17/.suo differ diff --git a/Test_VersionComparsion/App.config b/Test_VersionComparsion/App.config new file mode 100644 index 0000000..ecdcf8a --- /dev/null +++ b/Test_VersionComparsion/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Test_VersionComparsion/Form1.Designer.cs b/Test_VersionComparsion/Form1.Designer.cs new file mode 100644 index 0000000..e6d84ef --- /dev/null +++ b/Test_VersionComparsion/Form1.Designer.cs @@ -0,0 +1,131 @@ +namespace Test_VersionComparsion +{ + partial class Form1 + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.buttonRunProgram = new System.Windows.Forms.Button(); + this.groupBoxProgramInfo = new System.Windows.Forms.GroupBox(); + this.labelProgramInfo = new System.Windows.Forms.Label(); + this.groupBoxDLLInfo = new System.Windows.Forms.GroupBox(); + this.labelDLLInfo = new System.Windows.Forms.Label(); + this.labelResult = new System.Windows.Forms.Label(); + this.groupBoxProgramInfo.SuspendLayout(); + this.groupBoxDLLInfo.SuspendLayout(); + this.SuspendLayout(); + // + // buttonRunProgram + // + this.buttonRunProgram.Location = new System.Drawing.Point(12, 287); + this.buttonRunProgram.Name = "buttonRunProgram"; + this.buttonRunProgram.Size = new System.Drawing.Size(776, 23); + this.buttonRunProgram.TabIndex = 0; + this.buttonRunProgram.Text = "Programm ausführen"; + this.buttonRunProgram.UseVisualStyleBackColor = true; + this.buttonRunProgram.Click += new System.EventHandler(this.buttonRunProgram_Click); + // + // groupBoxProgramInfo + // + this.groupBoxProgramInfo.Controls.Add(this.labelProgramInfo); + this.groupBoxProgramInfo.Location = new System.Drawing.Point(12, 372); + this.groupBoxProgramInfo.Name = "groupBoxProgramInfo"; + this.groupBoxProgramInfo.Size = new System.Drawing.Size(385, 66); + this.groupBoxProgramInfo.TabIndex = 11; + this.groupBoxProgramInfo.TabStop = false; + this.groupBoxProgramInfo.Text = "Programm Information"; + // + // labelProgramInfo + // + this.labelProgramInfo.AutoSize = true; + this.labelProgramInfo.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelProgramInfo.Location = new System.Drawing.Point(7, 20); + this.labelProgramInfo.Name = "labelProgramInfo"; + this.labelProgramInfo.Size = new System.Drawing.Size(16, 13); + this.labelProgramInfo.TabIndex = 0; + this.labelProgramInfo.Text = "..."; + // + // groupBoxDLLInfo + // + this.groupBoxDLLInfo.Controls.Add(this.labelDLLInfo); + this.groupBoxDLLInfo.Location = new System.Drawing.Point(403, 372); + this.groupBoxDLLInfo.Name = "groupBoxDLLInfo"; + this.groupBoxDLLInfo.Size = new System.Drawing.Size(385, 66); + this.groupBoxDLLInfo.TabIndex = 12; + this.groupBoxDLLInfo.TabStop = false; + this.groupBoxDLLInfo.Text = "DLL Information"; + // + // labelDLLInfo + // + this.labelDLLInfo.AutoSize = true; + this.labelDLLInfo.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelDLLInfo.Location = new System.Drawing.Point(7, 20); + this.labelDLLInfo.Name = "labelDLLInfo"; + this.labelDLLInfo.Size = new System.Drawing.Size(16, 13); + this.labelDLLInfo.TabIndex = 0; + this.labelDLLInfo.Text = "..."; + // + // labelResult + // + this.labelResult.AutoSize = true; + this.labelResult.Location = new System.Drawing.Point(12, 13); + this.labelResult.Name = "labelResult"; + this.labelResult.Size = new System.Drawing.Size(16, 13); + this.labelResult.TabIndex = 13; + this.labelResult.Text = "..."; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.labelResult); + this.Controls.Add(this.groupBoxProgramInfo); + this.Controls.Add(this.groupBoxDLLInfo); + this.Controls.Add(this.buttonRunProgram); + this.Name = "Form1"; + this.Text = "Test_VersionComparsion"; + this.Load += new System.EventHandler(this.Form1_Load); + this.groupBoxProgramInfo.ResumeLayout(false); + this.groupBoxProgramInfo.PerformLayout(); + this.groupBoxDLLInfo.ResumeLayout(false); + this.groupBoxDLLInfo.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonRunProgram; + private System.Windows.Forms.GroupBox groupBoxProgramInfo; + private System.Windows.Forms.Label labelProgramInfo; + private System.Windows.Forms.GroupBox groupBoxDLLInfo; + private System.Windows.Forms.Label labelDLLInfo; + private System.Windows.Forms.Label labelResult; + } +} + diff --git a/Test_VersionComparsion/Form1.cs b/Test_VersionComparsion/Form1.cs new file mode 100644 index 0000000..79d44cc --- /dev/null +++ b/Test_VersionComparsion/Form1.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Eugen.ESystem; +using Eugen.ESystem.IO; + +namespace Test_VersionComparsion +{ + public partial class Form1 : Form + { + #region Version und Copyright + // Version und Copyright + string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = GenerateCopyright(); + string icon = Application.StartupPath + "\\Info.bmp"; + + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + + private static DateTime AssemblyDateTime() + { + var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); + //Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original) + return buildDateTime; + } + + private static string CurrentYear() + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + + private static string StartYear() + { + string startYear = ""; + if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © ")) + { + startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", ""); + while (startYear.StartsWith(" ")) + { + startYear = startYear.Remove(0, 1); + } + + if (startYear.Contains("-")) + { + startYear = startYear.Remove(startYear.IndexOf("-")); + } + else + { + startYear = startYear.Remove(startYear.IndexOf(" ")); + } + return startYear; + } + else + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + } + + private static string GenerateCopyright() + { + string startYear = StartYear(); + string currentYear = CurrentYear(); + + if (startYear == currentYear) + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + else + { + string temp = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + string start = temp.Remove(temp.IndexOf(startYear) - 1); + string end = (temp.Remove(0, temp.IndexOf(" by"))); + + return String.Concat(start, " ", startYear, "-", currentYear, end); + } + } + #endregion + + #region Programm-Info + /// + /// Contains the name of the program file + /// + public static string ProgramName { set; get; } + + /// + /// Contains the version of the program file + /// + public static string ProgramVersion { set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { set; get; } + + private void SetProgramInfo() + { + //Name, Version und Copyright setzen + ProgramName = programName; + ProgramVersion = programVersion; + Copyright = copyright; + } + #endregion + + public Form1() + { + SetProgramInfo(); + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + labelProgramInfo.Text = String.Concat(ProgramName, "\r\n", ProgramVersion, "\r\n", Copyright); // Zeigt die Programm-Information an + + labelDLLInfo.Text = String.Concat(VersionComparison.DllName, "\r\n", VersionComparison.DllVersion, "\r\n", VersionComparison.Copyright); // Zeigt die DLL-Information an + } + + private void buttonRunProgram_Click(object sender, EventArgs e) + { + string version = "1.2.3456.7890"; + string appVersion = ShowTextFile.DllVersion; + string comparsion = VersionComparison.Compare(version, appVersion).ToString(); + + labelResult.Text = "Vergleich von Version " + version + " mit der Revision " + appVersion + " von 'heshowtf.dll'.\r\nDie Funktion 'VersionComparsion' gibt " + comparsion + " zurück."; + } + } +} diff --git a/Test_VersionComparsion/Form1.resx b/Test_VersionComparsion/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Test_VersionComparsion/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test_VersionComparsion/Program.cs b/Test_VersionComparsion/Program.cs new file mode 100644 index 0000000..b2813cf --- /dev/null +++ b/Test_VersionComparsion/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Test_VersionComparsion +{ + internal static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Test_VersionComparsion/Properties/AssemblyInfo.cs b/Test_VersionComparsion/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fd6c905 --- /dev/null +++ b/Test_VersionComparsion/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("Test_VersionComparsion")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Test_VersionComparsion")] +[assembly: AssemblyCopyright("Copyright © 2022 by Eugen Höglinger")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("4060869d-db17-4677-9b34-ea09b1a11c44")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +//[assembly: AssemblyFileVersion("1.0.0.0")] //Wenn auskommentiert, dann gleich wie AssemblyVersion! diff --git a/Test_VersionComparsion/Properties/Resources.Designer.cs b/Test_VersionComparsion/Properties/Resources.Designer.cs new file mode 100644 index 0000000..67bed47 --- /dev/null +++ b/Test_VersionComparsion/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace Test_VersionComparsion.Properties { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_VersionComparsion.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Test_VersionComparsion/Properties/Resources.resx b/Test_VersionComparsion/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Test_VersionComparsion/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test_VersionComparsion/Properties/Settings.Designer.cs b/Test_VersionComparsion/Properties/Settings.Designer.cs new file mode 100644 index 0000000..74acc7f --- /dev/null +++ b/Test_VersionComparsion/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace Test_VersionComparsion.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Test_VersionComparsion/Properties/Settings.settings b/Test_VersionComparsion/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Test_VersionComparsion/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Test_VersionComparsion/Test_VersionComparsion.csproj b/Test_VersionComparsion/Test_VersionComparsion.csproj new file mode 100644 index 0000000..532c1e6 --- /dev/null +++ b/Test_VersionComparsion/Test_VersionComparsion.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {4060869D-DB17-4677-9B34-EA09B1A11C44} + WinExe + Test_VersionComparsion + Test_VersionComparsion + v4.7.2 + 512 + true + false + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\VersionComparison\bin\Debug\heshowtf.dll + + + ..\VersionComparison\bin\Debug\hevercom.dll + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.exe b/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.exe new file mode 100644 index 0000000..fa5193b Binary files /dev/null and b/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.exe differ diff --git a/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.exe.config b/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.exe.config new file mode 100644 index 0000000..ecdcf8a --- /dev/null +++ b/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.exe.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.pdb b/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.pdb new file mode 100644 index 0000000..b02debc Binary files /dev/null and b/Test_VersionComparsion/bin/Debug/Test_VersionComparsion.pdb differ diff --git a/Test_VersionComparsion/bin/Debug/heshowtf.dll b/Test_VersionComparsion/bin/Debug/heshowtf.dll new file mode 100644 index 0000000..5b6654e Binary files /dev/null and b/Test_VersionComparsion/bin/Debug/heshowtf.dll differ diff --git a/Test_VersionComparsion/bin/Debug/hevercom.dll b/Test_VersionComparsion/bin/Debug/hevercom.dll new file mode 100644 index 0000000..4691ebf Binary files /dev/null and b/Test_VersionComparsion/bin/Debug/hevercom.dll differ diff --git a/Test_VersionComparsion/bin/Debug/hevercom.pdb b/Test_VersionComparsion/bin/Debug/hevercom.pdb new file mode 100644 index 0000000..f3c0d8c Binary files /dev/null and b/Test_VersionComparsion/bin/Debug/hevercom.pdb differ diff --git a/Test_VersionComparsion/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/Test_VersionComparsion/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/Test_VersionComparsion/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/Test_VersionComparsion/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Test_VersionComparsion/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..2d8a026 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Test_VersionComparsion/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Test_VersionComparsion/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..d7f7141 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Test_VersionComparsion/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll b/Test_VersionComparsion/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll new file mode 100644 index 0000000..b7bd8a0 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll differ diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.Form1.resources b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.Form1.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.Form1.resources differ diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.Properties.Resources.resources b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.Properties.Resources.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.Properties.Resources.resources differ diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.AssemblyReference.cache b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.AssemblyReference.cache new file mode 100644 index 0000000..f7d10c2 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.AssemblyReference.cache differ diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.CopyComplete b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.CopyComplete new file mode 100644 index 0000000..e69de29 diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.CoreCompileInputs.cache b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..f799700 --- /dev/null +++ b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +71ebc7877c29a84a65014c3b8d168f59856d32e1 diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.FileListAbsolute.txt b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..52bde2f --- /dev/null +++ b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.FileListAbsolute.txt @@ -0,0 +1,15 @@ +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.csproj.AssemblyReference.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.csproj.SuggestedBindingRedirects.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.Form1.resources +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.Properties.Resources.resources +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.csproj.GenerateResource.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.csproj.CoreCompileInputs.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\bin\Debug\Test_VersionComparsion.exe.config +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\bin\Debug\Test_VersionComparsion.exe +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\bin\Debug\Test_VersionComparsion.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\bin\Debug\hevercom.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\bin\Debug\hevercom.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.csproj.CopyComplete +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.exe +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\obj\Debug\Test_VersionComparsion.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\Test_VersionComparsion\bin\Debug\heshowtf.dll diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.GenerateResource.cache b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.GenerateResource.cache new file mode 100644 index 0000000..62d2ff6 Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.GenerateResource.cache differ diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.SuggestedBindingRedirects.cache b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.csproj.SuggestedBindingRedirects.cache new file mode 100644 index 0000000..e69de29 diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.exe b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.exe new file mode 100644 index 0000000..fa5193b Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.exe differ diff --git a/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.pdb b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.pdb new file mode 100644 index 0000000..b02debc Binary files /dev/null and b/Test_VersionComparsion/obj/Debug/Test_VersionComparsion.pdb differ diff --git a/VersionComparison.sln b/VersionComparison.sln new file mode 100644 index 0000000..ad5f315 --- /dev/null +++ b/VersionComparison.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionComparison", "VersionComparison\VersionComparison.csproj", "{D7A07AD6-BD81-495E-AF8B-7219B71E97DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_VersionComparsion", "Test_VersionComparsion\Test_VersionComparsion.csproj", "{4060869D-DB17-4677-9B34-EA09B1A11C44}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D7A07AD6-BD81-495E-AF8B-7219B71E97DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7A07AD6-BD81-495E-AF8B-7219B71E97DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7A07AD6-BD81-495E-AF8B-7219B71E97DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7A07AD6-BD81-495E-AF8B-7219B71E97DB}.Release|Any CPU.Build.0 = Release|Any CPU + {4060869D-DB17-4677-9B34-EA09B1A11C44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4060869D-DB17-4677-9B34-EA09B1A11C44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4060869D-DB17-4677-9B34-EA09B1A11C44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4060869D-DB17-4677-9B34-EA09B1A11C44}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2D301A6E-5C6F-4B10-B76E-BC3CD61C4027} + EndGlobalSection +EndGlobal diff --git a/VersionComparison/Properties/AssemblyInfo.cs b/VersionComparison/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..600f4b6 --- /dev/null +++ b/VersionComparison/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("VersionComparison")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("VersionComparison")] +[assembly: AssemblyCopyright("Copyright © 2021 by Eugen Höglinger")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("d7a07ad6-bd81-495e-af8b-7219b71e97db")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +//[assembly: AssemblyFileVersion("1.0.0.0")] //Wenn auskommentiert, dann gleich wie AssemblyVersion! diff --git a/VersionComparison/VersionComparison.cs b/VersionComparison/VersionComparison.cs new file mode 100644 index 0000000..9f83c14 --- /dev/null +++ b/VersionComparison/VersionComparison.cs @@ -0,0 +1,213 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; + +namespace Eugen.ESystem +{ + public class VersionComparison + { + #region Version und Copyright + // Version und Copyright + static string dllName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + static string dllVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + static string copyright = GenerateCopyright(); + + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + static string date = value.ToShortDateString(); + static string time = value.ToLongTimeString(); + + private static DateTime AssemblyDateTime() + { + var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); + //Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original) + return buildDateTime; + } + + private static string CurrentYear() + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + + private static string StartYear() + { + string startYear = ""; + if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © ")) + { + startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", ""); + while (startYear.StartsWith(" ")) + { + startYear = startYear.Remove(0, 1); + } + + if (startYear.Contains("-")) + { + startYear = startYear.Remove(startYear.IndexOf("-")); + } + else + { + startYear = startYear.Remove(startYear.IndexOf(" ")); + } + return startYear; + } + else + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + } + + private static string GenerateCopyright() + { + string startYear = StartYear(); + string currentYear = CurrentYear(); + + if (startYear == currentYear) + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + else + { + string temp = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + string start = temp.Remove(temp.IndexOf(startYear) - 1); + string end = (temp.Remove(0, temp.IndexOf(" by"))); + + return String.Concat(start, " ", startYear, "-", currentYear, end); + } + } + #endregion + + #region DLL-Info + /// + /// Contains the name of the dll file. + /// + public static string DllName { private set; get; } + + /// + /// Contains the version of the dll file. + /// + public static string DllVersion { private set; get; } + + /// + /// Contains the copyright notice. + /// + public static string Copyright { private set; get; } + + /// + /// Contains the name-, version- and copyright-information of the dll file. + /// + public static string[] DllInfo { private set; get; } + + private static void SetDllInfo() + { + //Name, Version und Copyright setzen + DllName = dllName; + DllVersion = dllVersion; + Copyright = copyright; + + string[] dllInfo = new string[3]; + dllInfo[0] = dllName; + dllInfo[1] = dllVersion; + dllInfo[2] = copyright; + DllInfo = dllInfo; + } + + protected string ProgramName { private set; get; } + protected string ProgramVersion { private set; get; } + protected string ProgramCopyright { private set; get; } + #endregion + + static VersionComparison() + { + SetDllInfo(); + } + + /// + /// Compare a specified version with the version of an app + /// + /// String formatted as 'Majorversion.Minorversion.Buildnumber.Revision'. + /// A valid App version, e.g.: ShowTextFile.DllVersion + /// -1 = No valid comparison + /// 0 = Both versions the same + /// 1 = 'version' is newer than app version + /// 2 = Version of the app is newer than 'version' + public static int Compare(string version, string appVersion) + { + if (!IsVersionValid(version) || String.IsNullOrEmpty(appVersion)) + { + return -1; + } + + string[] versionSegment = version.Split('.'); + string[] appVersionSegment = appVersion.Split('.'); + + if (version == appVersion) + { + return 0; // Versionen sind gleich + } + + // Vergleich Hauptversion + if (Convert.ToInt16(versionSegment[0]) > Convert.ToInt16(appVersionSegment[0])) + { + return 1; //'version' neuer als 'appVersion' + } + if (Convert.ToInt16(versionSegment[0]) < Convert.ToInt16(appVersionSegment[0])) + { + return 2; //'appVersion' neuer als 'version' + } + + // Vergleich Nebenversion + if (Convert.ToInt16(versionSegment[1]) > Convert.ToInt16(appVersionSegment[1])) + { + return 1; //'version' neuer als 'appVersion' + } + if (Convert.ToInt16(versionSegment[1]) < Convert.ToInt16(appVersionSegment[1])) + { + return 2; //'appVersion' neuer als 'version' + } + + // Vergleich Buildnummer + if (Convert.ToInt16(versionSegment[2]) > Convert.ToInt16(appVersionSegment[21])) + { + return 1; //'version' neuer als 'appVersion' + } + if (Convert.ToInt16(versionSegment[2]) < Convert.ToInt16(appVersionSegment[2])) + { + return 2; //'appVersion' neuer als 'version' + } + + // Vergleich Revision + if (Convert.ToInt16(versionSegment[3]) > Convert.ToInt16(appVersionSegment[3])) + { + return 1; //'version' neuer als 'appVersion' + } + if (Convert.ToInt16(versionSegment[3]) < Convert.ToInt16(appVersionSegment[3])) + { + return 2; //'appVersion' neuer als 'version' + } + + return -1; //Kein gültiger Vergleich + } + + private static bool IsVersionValid(string version) + { + if (String.IsNullOrEmpty(version) || CountPoints(version) != 3) + { + return false; + } + else + { + return true; + } + } + + private static int CountPoints(string version) + { + return version.Count(c => c == '.'); //Zeichen zählen mit Linq + } + } +} diff --git a/VersionComparison/VersionComparison.csproj b/VersionComparison/VersionComparison.csproj new file mode 100644 index 0000000..0da6e23 --- /dev/null +++ b/VersionComparison/VersionComparison.csproj @@ -0,0 +1,48 @@ + + + + + Debug + AnyCPU + {D7A07AD6-BD81-495E-AF8B-7219B71E97DB} + Library + Properties + VersionComparison + hevercom + v4.7.2 + 512 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VersionComparison/bin/Debug/heshowtf.dll b/VersionComparison/bin/Debug/heshowtf.dll new file mode 100644 index 0000000..5b6654e Binary files /dev/null and b/VersionComparison/bin/Debug/heshowtf.dll differ diff --git a/VersionComparison/bin/Debug/hevercom.dll b/VersionComparison/bin/Debug/hevercom.dll new file mode 100644 index 0000000..4691ebf Binary files /dev/null and b/VersionComparison/bin/Debug/hevercom.dll differ diff --git a/VersionComparison/bin/Debug/hevercom.pdb b/VersionComparison/bin/Debug/hevercom.pdb new file mode 100644 index 0000000..f3c0d8c Binary files /dev/null and b/VersionComparison/bin/Debug/hevercom.pdb differ diff --git a/VersionComparison/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/VersionComparison/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/VersionComparison/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/VersionComparison/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/VersionComparison/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..83c78e3 Binary files /dev/null and b/VersionComparison/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/VersionComparison/obj/Debug/VersionComparison.csproj.AssemblyReference.cache b/VersionComparison/obj/Debug/VersionComparison.csproj.AssemblyReference.cache new file mode 100644 index 0000000..ce6c4ca Binary files /dev/null and b/VersionComparison/obj/Debug/VersionComparison.csproj.AssemblyReference.cache differ diff --git a/VersionComparison/obj/Debug/VersionComparison.csproj.CoreCompileInputs.cache b/VersionComparison/obj/Debug/VersionComparison.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..1284e03 --- /dev/null +++ b/VersionComparison/obj/Debug/VersionComparison.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +29ebf7ef8dbfa010194ad52c80fb65f004e30ac0 diff --git a/VersionComparison/obj/Debug/VersionComparison.csproj.FileListAbsolute.txt b/VersionComparison/obj/Debug/VersionComparison.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..93eca3f --- /dev/null +++ b/VersionComparison/obj/Debug/VersionComparison.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\VersionComparison\obj\Debug\VersionComparison.csproj.AssemblyReference.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\VersionComparison\obj\Debug\VersionComparison.csproj.CoreCompileInputs.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\VersionComparison\bin\Debug\hevercom.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\VersionComparison\bin\Debug\hevercom.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\VersionComparison\obj\Debug\hevercom.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\VersionComparison.git\VersionComparison\obj\Debug\hevercom.pdb diff --git a/VersionComparison/obj/Debug/hevercom.dll b/VersionComparison/obj/Debug/hevercom.dll new file mode 100644 index 0000000..4691ebf Binary files /dev/null and b/VersionComparison/obj/Debug/hevercom.dll differ diff --git a/VersionComparison/obj/Debug/hevercom.pdb b/VersionComparison/obj/Debug/hevercom.pdb new file mode 100644 index 0000000..f3c0d8c Binary files /dev/null and b/VersionComparison/obj/Debug/hevercom.pdb differ