12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /* ==============================================================================
- * 功能描述:App
- * 创 建 者:Garrett
- * 创建日期:2018/4/25 18:30:44
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using CEFSharpWpf;
- using SAGA.DotNetUtils;
- using SAGA.DotNetUtils.Others;
- using SAGA.MBI.Common;
- using SAGA.MBI.DataArrange;
- using SAGA.MBI.Model;
- using SAGA.MBI.WinView.Login;
- namespace SAGA.MBI
- {
- /// <summary>
- /// App
- /// </summary>
- class App
- {
- [STAThread]
- static void Main(string[] args)
- {
- #if DEBUG
- WinLogin win = new WinLogin();
- Application myAp = new Application();
- myAp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
- myAp.Run(win);
- #else
- string fullPath = Path.Combine(AppBaseInfo.AppRunPath, "Updater", "Update.exe");
- //有参数时直接启动
- if (args != null && args.Length > 0 || !File.Exists(fullPath))
- {
- WinLogin win = new WinLogin();
- Application myAp = new Application();
- myAp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
- myAp.Run(win);
- }
- else
- {
- try
- {
- //无参数可看做双击启动,启动前检测版本
- //arguments参数用空格分开,"Program Files"使用时被拆分成两个参数,使用时请注意
- //设置启动动作,确保以管理员身份运行
- ProcessStartInfo startInfo = new ProcessStartInfo(fullPath)
- {
- UseShellExecute = true,
- Verb = "runas",
- WindowStyle = ProcessWindowStyle.Normal,
- Arguments = Assembly.GetExecutingAssembly().Location,
- CreateNoWindow = true
- };
- Process.Start(startInfo);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.StackTrace);
- }
-
- }
- #endif
- }
- }
- }
|