using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.Library; using Dongke.IBOSS.PRD.Client.CommonModule; namespace Dongke.IBOSS.PRD.Client.Public { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new F_P_00001()); // 检查程序是否已经在运行中 bool isCreatedNew = true; string ibossMutexName = SystemAPI.UserName + "-iboss.prd.public-"; Mutex ibossMutex = new Mutex(true, ibossMutexName, out isCreatedNew); // 取得程序的版本 FileVersionInfo info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string _mainFormTitle = "查询系统" + " - " + Constant.M_SYSTEM_CHINESE_SERIES + " - ver " + info.FileVersion; if (isCreatedNew) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; { // 更新自动更新程序 if (Directory.Exists(LocalPath.InstallerPublicDownloadPath)) { string[] downFiles = Directory.GetFiles(LocalPath.InstallerPublicDownloadPath); if (downFiles.Length > 0) { foreach (string name in downFiles) { string filename = Path.GetFileName(name); if (filename.StartsWith("AutoUpgrade") || "SharpZipLib.dll".Equals(filename)) { string localFile = System.Environment.CurrentDirectory + @"\" + filename; if (File.Exists(localFile)) { File.Delete(localFile); } File.Copy(name, localFile); File.Delete(name); } } } } } // 主程序 using (F_P_00001 main = new F_P_00001()) { main.Text = _mainFormTitle; Application.Run(main); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException("PublicProgram.cs", "Main()", Messages.MSG_TITLE_E01, ex); } finally { if (ibossMutex != null) { ibossMutex.Close(); } } } else { IntPtr iptWndMain = Utility.FindWindow(null, _mainFormTitle); if (iptWndMain == IntPtr.Zero) { } else { Utility.WakeupWindow(iptWndMain); } } } private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { //throw new NotImplementedException(); ExceptionManager.HandleEventException( "PublicProgram.cs", "Application_ThreadException()", Messages.MSG_TITLE_E01, e.Exception); } } }