Jelajahi Sumber

windows下服务端进程创建黑窗口,否则不太方便关闭所有服务端进程

tanghai 7 tahun lalu
induk
melakukan
4d30557596
1 mengubah file dengan 4 tambahan dan 7 penghapusan
  1. 4 7
      Server/Model/Component/AppManagerComponent.cs

+ 4 - 7
Server/Model/Component/AppManagerComponent.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
+using System.Runtime.InteropServices;
 
 namespace ETModel
 {
@@ -49,18 +50,14 @@ namespace ETModel
 			StartConfigComponent startConfigComponent = Game.Scene.GetComponent<StartConfigComponent>();
 			string configFile = optionComponent.Options.Config;
 			StartConfig startConfig = startConfigComponent.Get(appId);
-#if __MonoCS__
-			const string exe = @"dotnet";
+			const string exe = "dotnet";
 			string arguments = $"App.dll --appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
-#else
-			const string exe = @"dotnet";
-			string arguments = $"App.dll --appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
-#endif
 
 			Log.Info($"{exe} {arguments}");
 			try
 			{
-				ProcessStartInfo info = new ProcessStartInfo { FileName = exe, Arguments = arguments, CreateNoWindow = true, UseShellExecute = false };
+				bool useShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+				ProcessStartInfo info = new ProcessStartInfo { FileName = exe, Arguments = arguments, CreateNoWindow = true, UseShellExecute = useShellExecute };
 
 				Process process = Process.Start(info);
 				this.processes.Add(startConfig.AppId, process);