if(NULL != pIHTMLDocument2)
{
IHTMLWindow2* pIHTMLWindow2 = NULL;
hr = pIHTMLDocument2->get_parentWindow(&pIHTMLWindow2);
if((S_OK == hr) && (NULL != pIHTMLWindow2))
{
IServiceProvider* pISP = NULL;
hr = pIHTMLWindow2->QueryInterface(IID_IServiceProvider, (void**)& pISP);
if((S_OK == hr) && (NULL != pISP))
{
IWebBrowser2* pIWebBrowser2 = NULL;
hr = pISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void**)& pIWebBrowser2);
if((S_OK == hr) && (NULL != pIWebBrowser2))
{
//…
}
pISP->Release();
}
pIHTMLWindow2->Release();
}
}