using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; using Lskj.Control; using Lskj.Util; using Xilium.CefGlue; namespace Lskj.Notice { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main(string[] args) { CefRuntime.Load();//cef浏览器模块设置加载 var mainArgs = new CefMainArgs(args); var app = new DemoApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, app); var settings = new CefSettings { MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Disable, LogFile = "CefGlue.log", Locale = "zh-CN" }; CefRuntime.Initialize(mainArgs, settings, app); try { bool isRunning = false; Mutex mutex = new Mutex(true, Process.GetCurrentProcess().ProcessName, out isRunning); if (isRunning) { Application.EnableVisualStyles(); AboutDevCompanion DC = new AboutDevCompanion(1, false); DC.Run(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain(args)); DC.Stop(); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); mutex.ReleaseMutex(); } else { //MessageUtil.Show("程序已启动."); if (!settings.MultiThreadedMessageLoop) { Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); }; CefRuntime.Shutdown(); } } } catch (Exception ex) { } } /// /// 说明:处理异常 /// 创建人:龚宇超 /// 创建日期:2017-11-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { MessageUtil.Show(e.Exception); LogHelper.Instance.WriteError(e.Exception); } /// /// 说明:处理异常 /// 创建人:王一帆 /// 创建日期:2021-07-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject.ToString()); MessageUtil.Show(e.ExceptionObject.ToString()); } class SingleApplication { [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] private static extern IntPtr OpenMutex(