簡體   English   中英

防止子進程在c#中顯示shell窗口

[英]Prevent child process from showing a shell window in c#

我正在使用ffmpeg編譯視頻,我想阻止它在執行操作時顯示控制台。

這是我開始ffmpeg的方式:

ProcessStartInfo si = new ProcessStartInfo();
si.Arguments = string.Format("-y -loop 1 -t " + DucationToString(frameDuration) + " -r 25 -f image2 -i \"{0}\" \"{1}\"",
                             item.Value, otpt);
si.FileName = "ffmpeg";
si.UseShellExecute = false;

Process.Start(si).WaitForExit();

無論我在ProcessStartInfo嘗試的設置,控制台始終顯示。

如何在創建子進程時阻止顯示控制台?

你應該嘗試使用

ProcessStartInfo si = new ProcessStartInfo();
si.WindowStyle = ProcessWindowStyle.Hidden;
si.CreateNoWindow = true;
si.UseShellExecute = false;

MSDN參考

ProcessStartInfo.CreateNoWindow設置為true

請注意

要使用ProcessWindowStyle.HiddenProcessStartInfo.CreateNoWindowProcessStartInfo.UseShellExecute屬性必須為false

您是否在代碼中添加了此內容

    si.CreateNoWindow = true;
    si.RedirectStandardOutput = true;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM