Skip to content

Commit

Permalink
feat: Vor Start des Programmes nach Updates schauen
Browse files Browse the repository at this point in the history
  • Loading branch information
JKamue committed Aug 23, 2024
1 parent 6a44c9a commit 93f70af
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using coIT.Lexoffice.GdiExport;

namespace coIT.Toolkit.Lexoffice.GdiExport
Expand All @@ -10,10 +11,50 @@ internal static class Program
[STAThread]
static void Main()
{
var updatesWurdenGefundenUndWerdenDurchgeführt = UpdaterAktualisiertAnwendung();

// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
if (!updatesWurdenGefundenUndWerdenDurchgeführt)
{
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
}
}

public static bool UpdaterAktualisiertAnwendung()
{
var updaterPfad = ErwarteterPfadFürUpdater();
if (File.Exists(updaterPfad))
{
Process process = Process.Start(updaterPfad);
process.WaitForExit();
var code = process.ExitCode;
process.Close();

// Updater exit code 0 bedeutet, dass Updates gefunden wurden
// https://www.advancedinstaller.com/user-guide/updater.html#section370
var updateGefundenExitCode = 0;
return code == updateGefundenExitCode;
}
return false;
}

public static string ErwarteterPfadFürUpdater()
{
#if DEBUG
var appdataOrdner = Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData
);
return Path.Combine(
appdataOrdner,
"co-IT.eu GmbH",
"Lexoffice Gdi Export",
"updater.exe"
);
#else
return Path.Combine(Application.StartupPath, "..", "updater.exe");
#endif
}
}
}

0 comments on commit 93f70af

Please sign in to comment.