Program.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* This file is part of SevenZipSharp.
  2. SevenZipSharp is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU Lesser General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. SevenZipSharp is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public License
  11. along with SevenZipSharp. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. using System;
  14. using System.Windows.Forms;
  15. namespace AutomaticUpdate
  16. {
  17. static class Program
  18. {
  19. /// <summary>
  20. /// The main entry point for the application.
  21. /// </summary>
  22. [STAThread]
  23. static void Main(string[] args)
  24. {
  25. if (args.Length > 0)
  26. {
  27. FormMain.KillPath = args[0].Replace("|"," ");
  28. if (args.Length > 1)
  29. {
  30. FormMain.InputCompressFilePath = args[1].Replace("|", " ");
  31. }
  32. }
  33. System.Threading.Thread.Sleep(1500);
  34. Application.EnableVisualStyles();
  35. Application.SetCompatibleTextRenderingDefault(false);
  36. Application.ThreadException += Application_ThreadException;
  37. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  38. Application.Run(new FormMain());
  39. }
  40. static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  41. {
  42. Exception Exception = (Exception)e.ExceptionObject;
  43. MessageBox.Show("更新失败,请关闭正在运行的程序后重试。\r\n错误原因:" + Exception.Message);
  44. // if (System.IO.File.Exists(FormMain.runApplicationPath))
  45. // {
  46. // FormMain.RunStart(FormMain.runApplicationPath);
  47. // }
  48. Application.ExitThread();
  49. Application.Exit();
  50. }
  51. static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
  52. {
  53. MessageBox.Show("更新失败,请关闭正在运行的程序后重试。\r\n错误原因:" + e.Exception.Message.ToString());
  54. Application.ExitThread();
  55. Application.Exit();
  56. }
  57. }
  58. }