I've seen a number of BHO samples and I try to implement this common scenario:
STDMETHODIMP CBhoImpl::SetSite(IUnknown* pSite)
{
if (NULL != pSite)
{
CComQIPtr<IWebBrowser2> webBrowser(pSite);
// webBrowser should hold a non-null pointer here
// but it holds a null pointer instead
//whatever
}
// whatever
}
SetSite() is invoked and the if branch is entered but QueryInterface() fails to retrieve IWebBrowser2.
I've seen a number of examples doing exactly the same.
What am I doing wrong?
Try querying the
IUnknownparameter forIServiceProvider, and if successful then you can call itsQueryService()method to get theIWebBrowser2, eg: