using HslCommunication; using JY.Utility; using System; using System.Reflection; using System.Threading; using System.Windows.Forms; namespace JY.Inspection { static class Program { public delegate void RunWorkHandler(); private static HomeForm mFrmMain; /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { if (Authorization.SetAuthorizationCode("b5f8f9f7-c075-4913-ae6e-d7d2cc6f2de1")) { Console.WriteLine("注册成功"); } try { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IniFileHelper.CreateIniFile(Application.StartupPath + "\\Config\\", "Configure.ini"); string mutexName = Assembly.GetEntryAssembly().FullName; string title = IniFileHelper.ReadIniData("SYSTEM_CONFIGURE", "Project_Name"); mFrmMain = new HomeForm(); bool isFirst; using (new Mutex(false, mutexName, out isFirst)) { if (!isFirst) { MessageBox.Show(title + " 已运行,请勿重复启动!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else { Application.Run(mFrmMain); } } } catch (Exception ex) { LogHelper.WriteException(ex, string.Empty); } } private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { LogHelper.WriteException(e.Exception, string.Empty); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { LogHelper.WriteException(e.ExceptionObject as Exception, e.ToString()); } } }