我可以使用ShellExecuteEx成功運行一個新進程,但是如果我訪問HasExited屬性,則會引發Win32Exception。什麼是這個異常,我如何檢查過程是否還活着?爲什麼hasExited拋出'System.ComponentModel.Win32Exception'?
ShellExecuteEx(ref info);
clientProcessId = NativeMethods.GetProcessId(info.hProcess);
Process clientProcess = Process.GetProcessById((int)clientProcessId);
if (clientProcess.HasExited) //<---- throws Win32Exception, but the process is alive! I can see its window
{
//run new one
}
感謝
你能發佈一段代碼嗎? – 2009-04-21 21:43:40
我已經更新了這個問題。 – mimic 2009-04-21 22:10:16