views:

355

answers:

1

In my app, I want to open a new IE window, then receive and process DocumentComplete and NavigateComplete2 events fired from the new opened IE. In XP, everything works fine. In Vista, the new IE is running in Protected Mode, so my app is not able to receive DocumentCompelte event from the IE.

I do not want to change any security level, like open IE in Protected Mode off or lower my app integrity. I wonder if I can use ChangeWindowsMessageFilter to receive DocumentComplete and NavigateComplete2 events from Protected Mode IE? My code is like:

   ChangeWindowMessageFilter(DISPID_DOCUMENTCOMPELTE, MSGFLT_ADD );
   ChangeWindowMessageFilter(DISPID_NAVIGATECOMPLETE2, MSGFLT_ADD );

Thanks!

+1  A: 

No. ChangeWindowMessageFilter() only works on Window Messages (WM_CREATE, for example).

The DWebBrowserEvents2() "messages" are Dispinterface events invoked via COM, and have nothing to do with Window Messages.

Edit:

From the documentation:

If your application launches Internet Explorer using CoCreateInstance and you need to continue controlling navigations after IE is launched, you can use IWebBrowser2 to navigate Internet Explorer programmatically. You can only continue controlling navigations after IE is launched if your application has the same integrity level as the IE process launched. Once your application navigates to URL in a different integrity IE process, you can not perform additional navigations. You should make the IE Frame visible after navigation.

So I suspect you're falling victim to some similar issue. You either need to run your process as a low integrity process, or run the webbrowser at higher integrity level. See this document for details on how to control how your app is launched (manifest).

If you don't actually need a full browser, consider CoCreateInstance(CLSID_WebBrowser).

jeffamaphone
Is there a way to open the blocked Dispinterface events in Vista? Thanks!
bionicoder
I don't think you're asking the right questions, since your questions don't make any sense. How are you subscribing to the events in the first place?
jeffamaphone
My question does make sense. here is how I subscribe to the events.hr = pNewBrowserEvtHandlerObj->DispEventAdvise(m_spNewWebBrowser2);Even UAC is on, the return hr is S_OK, so the event subscribing is good. The only thing is no events coming in. If UAC is off, or running the app as administrator, then everything is ok.
bionicoder
How are you creating the WebBrowser2?
jeffamaphone
Here is the code to create new web browser.m_spNewWebBrowser2.CoCreateInstance(CLSID_InternetExplorer);
bionicoder
Okay, more details above.
jeffamaphone