views:

479

answers:

1

The following code, on Vista with Internet Explorer 7, opens two windows (the one I create, and then a second one when Navigate is called, which is the one that the file appears in). This doesn't happen in Internet Explorer 8, or on XP as far as I know. Any idea how I can stop it doing that?

     SHDocVw.InternetExplorerClass ieObject = (SHDocVw.InternetExplorerClass)this.ieObject;
     if (this.ieObject == null)
     {
        ieObject = new SHDocVw.InternetExplorerClass();
        this.ieObject = ieObject;
     }

     SHDocVw.IWebBrowser2 browserApp = (SHDocVw.IWebBrowser2)this.ieObject;
     object empty = System.Reflection.Missing.Value;
     browserApp.Visible = true;
     User32.SetForegroundWindow(new IntPtr(browserApp.HWND));
     browserApp.Navigate(filePath, ref empty, ref empty, ref empty, ref empty);
A: 

Are you navigating to a trusted web site? If the navigation would cross integrity levels, IE has to create a new process for that integrity level. IE8 can handle this in the same window because tabs and the frame can be in different processes. IE7 does not support tab processes.

If your process is in protected mode, you can not gain access to process with higher integrity levels. A walk around is to write IE extension that would run in the target process to relay your commands.

Sheng Jiang 蒋晟