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?你应该阅读这个问题以得到更详细的答案