|
@@ -0,0 +1,69 @@
|
|
|
+/* ==============================================================================
|
|
|
+ * 功能描述:App
|
|
|
+ * 创 建 者:Garrett
|
|
|
+ * 创建日期:2019/11/8 9:23:25
|
|
|
+ * ==============================================================================*/
|
|
|
+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;
|
|
|
+
|
|
|
+namespace LRH
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// App
|
|
|
+ /// </summary>
|
|
|
+ public class App
|
|
|
+ {
|
|
|
+ [STAThread]
|
|
|
+ static void Main(string[] args)
|
|
|
+ {
|
|
|
+#if DEBUG
|
|
|
+ MainWindow win = new MainWindow();
|
|
|
+ Application myAp = new Application();
|
|
|
+ myAp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
|
|
+ myAp.Run(win);
|
|
|
+#else
|
|
|
+ var runPath=Directory.GetParent(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)).ToString();
|
|
|
+ string fullPath = Path.Combine(runPath, "Updater", "Update.exe");
|
|
|
+
|
|
|
+ //有参数时直接启动
|
|
|
+ if (args != null && args.Length > 0 || !File.Exists(fullPath))
|
|
|
+ {
|
|
|
+ MainWindow win = new MainWindow();
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|