增加一個event 讓 Process 在執行完畢的時候判斷用
private static void process_Exited(object sender, EventArgs e) {
Console.WriteLine("Notepad.exe 已被關閉!!!");
}
程式的寫法:
System.Diagnostics.Process pr = new System.Diagnostics.Process();
pr.StartInfo.FileName = 執行檔的路徑,ex.c:\\Notepad.exe...之類的;
pr.StartInfo.Arguments = 需要執行的參數 ,ex. /s /e;
pr.Exited += new EventHandler(process_Exited);
pr.EnableRaisingEvents = true;
pr.Start(); //執行
執行後顯示:
參考來源:
[C#.NET] 判斷被呼叫的應用程式是否被關閉文章標籤
全站熱搜
留言列表