2013-05-03 23 views
0

我有一個疑問,當我創建一個新進程iexplore,並且此進程打開單個頁面時,我想知道該頁面是否正確加載。如何知道頁面加載失敗?有沒有辦法從iexplore過程中發現錯誤?創建進程並附上C#

我有這樣的演示代碼,但不能正常工作

string navegador = "C:\\program files (x86)\\Internet Explorer\\iexplore.exe"; 
Process p = new Process(); 
p.StartInfo.FileName = navegador; 
ProcessStartInfo processStartInfo = new ProcessStartInfo(navegador); 
p.EnableRaisingEvents = false; 
p.StartInfo.UseShellExecute = false; 
p.StartInfo.RedirectStandardOutput = true; 
p.StartInfo.RedirectStandardError = true; 
p.StartInfo.CreateNoWindow = true; 
p.StartInfo = processStartInfo; 
p.StartInfo.Arguments = "google.com"; 

p.Start(); 

Process currentProcess = Process.GetCurrentProcess(); 
Process[] localByName = Process.GetProcessesByName("iexplore"); 
Process[] localAll = Process.GetProcesses(); 


p.OutputDataReceived += new DataReceivedEventHandler(
         prsProjectTypes_OutputDataReceived); 
p.BeginOutputReadLine(); 

errorMessage = p.StandardError.ReadToEnd(); 
p.WaitForExit(); 

感謝您的任何幫助。

+0

很明顯,英語不是你的母語,這很好,但你的問題幾乎不可能理解。 – regretoverflow 2013-05-03 19:18:37

+0

試圖重述這個問題,請看看它是否更好,並且仍然反映您的任務。你能說出你想監視的確切的錯誤條件是什麼嗎? – oleksii 2013-05-03 19:40:29

回答

1

假設您正在使用WPF,您應該查看Web瀏覽器控件而不是啓動單獨的過程。這將讓你訪問LoadCompleted事件,這似乎是你在找什麼。