2012-04-04 50 views
1

我正在創建一個過程來完成一些工作。但是這個過程開始一個黑色的窗口(像cmd)。我試圖設置CreateNoWindow = true,但這沒有幫助。禁止窗口創建過程

是否有另一種方法來禁止窗口創建?

這裏是我的代碼:

var worker1 = new Process(); 

worker1.EnableRaisingEvents = true; 
worker1.StartInfo.CreateNoWindow = true; 
worker1.StartInfo.ErrorDialog = true; 
worker1.StartInfo.Arguments = job.BtcFilePath; 
worker1.StartInfo.FileName = job.ExeFilePath; 
worker1.Exited += new EventHandler(Worker1Exited); 

Processors.Add(worker1); 

Processors.Last().Start(); 
Processors.Last().PriorityClass = ProcessPriorityClass.BelowNormal; 

*處理器是處理器

BR

回答

3
worker1.StartInfo.CreateNoWindow = true; 
worker1.StartInfo.UseShellExecute = false; 

這在類似情況下爲我工作的列表。

worker1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 

這似乎是另一種選擇。 (沒有測試過這個,但是在瀏覽時發現了這個http://www.dotnetperls.com/png

+0

完美:D你能解釋一下它是什麼嗎? – Sulby 2012-04-04 08:13:42

+1

UseShellExecute的說明:'如果啓動進程時應該使用shell,則爲true;如果應該直接從可執行文件創建進程,則爲false。默認值爲true。' - shell管理所有的窗口(我認爲它無論如何都是這樣),所以不使用shell會停止創建窗口。 – Thomas 2012-04-04 08:27:43