Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么即使我将ProcessStartInfo的控制台窗口设置为隐藏,也会显示它?_C#_Winforms - Fatal编程技术网

C# 为什么即使我将ProcessStartInfo的控制台窗口设置为隐藏,也会显示它?

C# 为什么即使我将ProcessStartInfo的控制台窗口设置为隐藏,也会显示它?,c#,winforms,C#,Winforms,这是我无法理解的代码,为什么它会显示进程的控制台窗口 class Ffmpeg { NamedPipeServerStream p; String pipename = "mytestpipe"; byte[] b; System.Diagnostics.Process process; string ffmpegFileName; string workingDirectory;

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

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.WindowsStyle=ProcessWindowsStyle.Hidden;但当我运行这个过程时,我仍然看到了窗口。为什么会这样?

这就是问题的原因:

psi.CreateNoWindow = false;

应该是
true

这就是问题的原因:

psi.CreateNoWindow = false;

应该是
true

阅读文档,它通过屏幕截图显示
一个都不是什么样子http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle.aspx
CreateNoWindow=true?您应该阅读此问题以获得更详细的答案阅读文档,它通过屏幕截图显示了
无的外观http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle.aspx
CreateNoWindow=true?你应该阅读这个问题以得到更详细的答案