+44
@@ -0,0 +1,44 @@
|
||||
namespace BSO.Launcher;
|
||||
|
||||
static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static int Main(string[] args)
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
// Deinstallieren (aus "Apps & Features")
|
||||
if (args.Contains("--uninstall"))
|
||||
{
|
||||
Installer.Uninstall(args.Contains("--quiet"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Wie Discord: die heruntergeladene .exe installiert sich selbst und startet dann die installierte Kopie.
|
||||
// Ist schon dieselbe oder eine neuere Version installiert, wird einfach diese geoeffnet. --portable = ohne Installation.
|
||||
if (!Installer.RunningInstalled && !args.Contains("--portable"))
|
||||
{
|
||||
if (Installer.NeedsInstall()) Application.Run(new InstallForm());
|
||||
else Installer.StartInstalled();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Nur ein Launcher gleichzeitig
|
||||
using var single = new Mutex(true, "BSO-Launcher-Single", out bool first);
|
||||
// Nach einem Selbst-Update: die alte Version beendet sich gerade - bis zu 20 s auf sie warten
|
||||
if (!first && args.Contains(SelfUpdate.AfterUpdateArg))
|
||||
{
|
||||
try { first = single.WaitOne(TimeSpan.FromSeconds(20)); }
|
||||
catch (AbandonedMutexException) { first = true; } // alte Version wurde hart beendet - Sperre gehoert jetzt uns
|
||||
}
|
||||
if (!first)
|
||||
{
|
||||
MessageBox.Show("Der BSO Launcher laeuft schon.", Installer.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return 0;
|
||||
}
|
||||
SelfUpdate.CleanupOldVersion();
|
||||
if (Installer.RunningInstalled) Installer.Register(); // Version in "Apps & Features" nach einem Selbst-Update
|
||||
Application.Run(new MainForm());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user