How do I obtain a SHDocVw.InternetExplorer
Hi,
In this code I create an IE and call up a web page. I have the process ID and the SHDocVw.WebBrowser for the IE.
How can I get the SHDocVw.InternetExplorer?
protected virtual void StartBrowserInSeparateTask()
{
System.Diagnostics.Process procId;
//procId = System.Diagnostics.Process.Start("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE");
procId = System.Diagnostics.Process.Start("IEXPLORE.EXE");
// for every shell/browser
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
SHDocVw.InternetExplorer browser;
foreach (SHDocVw.WebBrowser webBrowser in shellWindows)
{
uint dwPID;
if (!webBrowser.FullName.ToLower().Contains("iexplore .exe"))
{
Debug.WriteLine(string.Format(" {0} is not a web browser", webBrowser.FullName));
continue;
}
Carefx.Tools.Win32Api.GetWindowThreadProcessId(new IntPtr(webBrowser.HWND), out dwPID);
if (dwPID == procId.Id)
{
// if the document is not ready, go on to the next
while (webBrowser.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
Thread.Sleep(200);
}
//this.browser = webBrowser;
}
}
}
|