-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
56 lines (54 loc) · 1.97 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
namespace mca_coh_gui
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
string mutexName = "mca-coh-gui";
System.Threading.Mutex mutex = new(false, mutexName);
bool hasHandle = false;
try
{
try
{
hasHandle = mutex.WaitOne(0, false);
}
catch (System.Threading.AbandonedMutexException)
{
hasHandle = true;
}
if (hasHandle == false)
{
MessageBox.Show("Multiple launch of applications is not allowed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\mca-coh.exe"))
{
MessageBox.Show("The required file 'mca-coh.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\updater.exe"))
{
MessageBox.Show("The required file 'updater.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ApplicationConfiguration.Initialize();
Application.Run(new FormMain());
}
finally
{
if (hasHandle)
{
mutex.ReleaseMutex();
}
mutex.Close();
}
}
}
}