领胜LDS 键盘AOI检测项目
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 Bro.Common.Helper;
using Bro.Common.Model.Authority;
using System;
using System.Threading;
using System.Windows.Forms;
 
namespace Bro.UI.Config
{
    static class Program
    {
        static MainFrm configFrm = null;
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            if (!AuthorityCheck.AuthorityCheckOperation())
            {
                MessageBox.Show("加密狗本地检测和远程检测失败!请本地插入加密狗或确认远程加密服务就绪。");
                Environment.Exit(1);
            }
 
            bool isAppRunning = false;
            Mutex mutex = new Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out isAppRunning);
            if (!isAppRunning)
            {
                MessageBox.Show("程序已运行,不能再次打开!");
                Environment.Exit(1);
            }
 
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
 
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
 
            configFrm = new MainFrm();
            Application.Run(configFrm);
 
            AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            Application.ThreadException -= Application_ThreadException;
        }
 
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            string msg = e.Exception.GetExceptionMessage();
            //mainFrm.RecordMsg(msg);
            //configFrm.RecordMsg(DateTime.Now, "ThreadException", msg, true);
            MessageBox.Show(msg);
        }
 
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string msg = (e.ExceptionObject as Exception).GetExceptionMessage();
            //configFrm.RecordMsg(DateTime.Now, "UnhandleException", msg, true);
            MessageBox.Show(msg);
        }
    }
}