Beispiel #1
0
        //C:\Program Files\YCRO\Digital 更新路径
        public static  void Runmain()
        {

            bool bCreatedNew;
            Mutex m = new Mutex(false, "myUniqueName", out bCreatedNew);



            RegistryKey YCRO = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Autodesk\AutoCAD\R16.2\ACAD-4001:409\Applications\YRO_Digital");

            object path=  YCRO.GetValue("LOADER");

            SoftUpdate app = new SoftUpdate(path.ToString(), "UpdateProgram.zip");

            app.UpdateFinish += new UpdateState(app_UpdateFinish);

            if (app.IsUpdate)
            {


                System.Diagnostics.Process.Start(Path.GetDirectoryName(path.ToString()) + "\\" + "UpdateSoftProgram.exe");
                Application.Exit();
                closeapp();

            }

            else
            {
                if (bCreatedNew)
                {
                   
                    //try
                    //{
                    //    ////处理未捕获的异常   
                    //    //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                    //    ////处理UI线程异常   
                    //    //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                    //    ////处理非UI线程异常   
                    //    //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                    //    Application.EnableVisualStyles();
                    //    Application.SetCompatibleTextRenderingDefault(false);
                    //    //LoginForm lform = new LoginForm();
                    //    //if (lform.ShowDialog() == DialogResult.OK)
                    //    //{
                    //    //    string sqlStr = string.Empty;
                    //    //    string user_name = lform.LoginUserName;
                    //    //    User.Get_CurrentUser(user_name);
                    //    //    Application.Run(new MDIForm());
                    //    //}
                    //}
                    //catch (System.Exception ex)
                    //{
                    //    string str = "";
                    //    string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";

                    //    if (ex != null)
                    //    {
                    //        str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                    //             ex.GetType().Name, ex.Message, ex.StackTrace);
                    //    }
                    //    else
                    //    {
                    //        str = string.Format("应用程序线程错误:{0}", ex);
                    //    }


                    //    writeLog(str);
                    //    MessageBox.Show(str);
                    //    //MessageBox.Show("发生致命错误,请及时联系作者!", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //    Application.Exit();

                    //}
                }
            }
        }
Beispiel #2
0
        static void Main()
        {
            bool bCreatedNew;
            Mutex m = new Mutex(false, "myUniqueName", out bCreatedNew);
            SoftUpdate app = new SoftUpdate(Application.ExecutablePath, "UpdateProgram.zip");

            app.UpdateFinish += new UpdateState(app_UpdateFinish);

            if (app.IsUpdate)
            {
                Application.Exit();
                System.Diagnostics.Process.Start(Application.StartupPath + "\\" + "UpdateSoftProgram.exe");
            }

            else
            {
                if (bCreatedNew)
                {
                    try
                    {
                        //处理未捕获的异常
                        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                        //处理UI线程异常
                        Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                        //处理非UI线程异常
                        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        LoginForm lform = new LoginForm();
                        if (lform.ShowDialog() == DialogResult.OK)
                        {
                            string sqlStr = string.Empty;
                            string user_name = lform.LoginUserName;
                            User.Get_CurrentUser(user_name);
                            Application.Run(new MDIForm());
                        }
                    }
                    catch (Exception ex)
                    {
                        string str = "";
                        string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";

                        if (ex != null)
                        {
                            str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                                 ex.GetType().Name, ex.Message, ex.StackTrace);
                        }
                        else
                        {
                            str = string.Format("应用程序线程错误:{0}", ex);
                        }

                        writeLog(str);
                        MessageBox.Show(str);
                        //MessageBox.Show("发生致命错误,请及时联系作者!", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Application.Exit();

                    }
                }
            }
        }