簡體   English   中英

ProcessStartInfo.UseShellExecute = true並等待進程退出

[英]ProcessStartInfo.UseShellExecute = true and waiting for process exit

我想使用shell可執行文件來尊重啟動應用程序的用戶首選項,但我還需要知道該特定應用程序何時關閉。

Process editProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = filename;
startInfo.Verb = "edit";
startInfo.UseShellExecute = true;
editProcess.StartInfo = startInfo;

// start the default editor
editProcess.Start();
editProcess.WaitForExit();

WaitForExit似乎在shell進程退出時返回,而不是在真正的進程退出時返回。

有沒有更好的方法知道何時啟動應用程序退出而不是手動解析注冊表,找到正確的應用程序啟動並顯式啟動該應用程序而不執行shell?

處理流程退出事件:

editProcess.Exited += process_Exited;

暫無
暫無

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

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