d23004
2023-05-24 fa87a558389d9d425f70afa1c8de54c69875ef2c
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
using SA_LTT;
using System;
using System.Threading;
using System.Windows.Forms;
 
namespace SA_LTT_UI
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
 
        private static Mutex _mutexObject;
        private static string _strAppConstName = "SALTT-01";
 
        [STAThread]
        static void Main()
        {
            OperatingSystem os = Environment.OSVersion;
            if ((os.Platform == PlatformID.Win32NT) && (os.Version.Major >= 5))
            {
                _strAppConstName = @"Global\" + _strAppConstName;
 
                try
                {
                    // 뮤텍스를 생성
                    _mutexObject = new Mutex(false, _strAppConstName);
                }
                catch (ApplicationException ex)
                {
                    EquipmentLogManager.Instance.WriteExceptionLog(ex.StackTrace + "\r\n" + ex.Message);
                    return;
                }
 
                if (_mutexObject.WaitOne(100, false))
                {
                    try
                    {
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new MainFrame());
 
                        _mutexObject.ReleaseMutex();
                    }
                    catch (ApplicationException ex)
                    {
                        EquipmentLogManager.Instance.WriteExceptionLog(ex.StackTrace + "\r\n" + ex.Message);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show(@"이미 실행되고 있습니다.", @"다중실행방지");
                }
                _mutexObject.Close();
            }
        }
    }
}