pUnkSite->QueryInterface(IID_IOleWindow) fails with E_NOINTERFACE in my BHO

375 Views Asked by At

I use Microsoft Visual C++ and Windows 7.
I am developing IE toolbar with ATL and MFC. IE version is 11.0.9600.17420.

First of all, I have created COM object implementing IDeskBand and IObjectWithSite interfaces.
Second, I have implemented IDeskBand methods and IObjectWithSite::SetSite method. It takes only one parameter, IUnknown *pUnkSite.

As I remember, I can do pUnkSite->QueryInterface(IID_IOleWindow, (void**)&pOleWindow); to get IOleWindow interface from site, and then I can call pOleWindow->GetWindow(&hWnd); to get parent window handle; so I can create my toolbar window as a child of window with this hWnd.

So I did it and realized that pUnkSite->QueryInterface(IID_IOleWindow, (void**)&pOleWindow); returns 0x80004002 which is E_NOINTERFACE error, so IOleWindow is not implemented by pUnkSite object! I opened IE in debugger, loaded symbols, traced to QISearch and realized that there is no implementation of IOleWindow interface. If I am not mistaken it was CIEFrameAuto interface.

So, how can I obtain IOleWindow interface for parent window for my toolbar?

0

There are 0 best solutions below