-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
83 lines (80 loc) · 3.36 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
namespace chusongtool
{
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 = "ChuSongTool";
Mutex mutex = new(false, mutexName);
bool hasHandle = false;
try
{
try
{
hasHandle = mutex.WaitOne(0, false);
}
catch (AbandonedMutexException)
{
hasHandle = true;
}
if (hasHandle == false)
{
MessageBox.Show("Multiple launch of applications is not allowed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Directory.Exists(Directory.GetCurrentDirectory() + @"\res\sat"))
{
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\sat\acbeditor.exe"))
{
MessageBox.Show("The required file 'acbeditor.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else
{
MessageBox.Show("The SonicAudioTools directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Directory.Exists(Directory.GetCurrentDirectory() + @"\res\dt\release"))
{
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\dt\release\hca2wav.exe"))
{
MessageBox.Show("The required file 'hca2wav.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\dt\release\hcaenc.exe"))
{
MessageBox.Show("The required file 'hcaenc.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\dt\release\hcacc.exe"))
{
MessageBox.Show("The required file 'hcacc.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else
{
MessageBox.Show("The DereTools directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ApplicationConfiguration.Initialize();
Application.Run(new FormMain());
}
finally
{
if (hasHandle)
{
mutex.ReleaseMutex();
}
mutex.Close();
}
}
}
}