【发布时间】:2020-12-03 17:21:22
【问题描述】:
我将一个 C# 程序编译为一个 exe 文件。当我从 Windows 资源管理器中双击 exe 文件时,程序启动时会出现一个黑色的命令行窗口。如何在不显示命令行窗口的情况下从 Windows 资源管理器启动此文件
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int HIDE = 0;
private const int MAXIMIZE = 3;
private const int MINIMIZE = 6;
private const int RESTORE = 9;
Process cmd = new Process();
cmd.StartInfo.FileName = Path.Combine(path, "Launcher.exe");
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine(argHandlerArgs);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
ShowWindow(cmd.MainWindowHandle, 0);
【问题讨论】:
-
它是下面堆栈溢出流问题stackoverflow.com/questions/3571627/…的副本
标签: c# console-application process.start