【问题标题】:Why the console window of the ProcessStartInfo is show even if i set it to be hidden?为什么 ProcessStartInfo 的控制台窗口即使我将其设置为隐藏也会显示?
【发布时间】:2013-06-07 08:30:20
【问题描述】:

这是我无法理解为什么它显示进程的控制台窗口的代码。

class Ffmpeg
    {
        NamedPipeServerStream p;
        String pipename = "mytestpipe";
        byte[] b;
        System.Diagnostics.Process process;
        string ffmpegFileName;
        string workingDirectory;

        public Ffmpeg()
        {
            workingDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath) + @"\workingDirectory";
            ffmpegFileName = @"\ffmpeg.exe";
            if (!Directory.Exists(workingDirectory))
            {
                Directory.CreateDirectory(workingDirectory);
            }
            ffmpegFileName = workingDirectory + ffmpegFileName;
        }

        public void Start(string pathFileName, int BitmapRate)
        {
            string outPath = pathFileName;
            p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
            b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p

            ProcessStartInfo psi = new ProcessStartInfo();
            psi.WindowStyle = ProcessWindowStyle.Hidden;
            psi.UseShellExecute = false;
            psi.CreateNoWindow = false;
            psi.FileName = ffmpegFileName;
            psi.WorkingDirectory = workingDirectory;
            psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + outPath;
            //psi.RedirectStandardOutput = true;
            process = Process.Start(psi);
            process.EnableRaisingEvents = false;
            p.WaitForConnection();
        }

我做了 psi.WindowStyle = ProcessWindowStyle.Hidden;但是当我运行该过程时,我仍然看到了窗口。这是为什么呢?

【问题讨论】:

  • 阅读文档,它用屏幕截图显示None look like http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle.aspx
  • CreateNoWindow = true; ? documentation
  • 你应该阅读这个问题以获得更详细的答案stackoverflow.com/questions/5094003/…

标签: c# winforms


【解决方案1】:

这是您的问题的原因:

psi.CreateNoWindow = false;

应该是true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-04
    • 2022-11-04
    • 2012-10-11
    相关资源
    最近更新 更多