IDispatch *idisp; webBrowser->get_Document(&idisp);
if (idisp && !doc) idisp->QueryInterface(IID_IHTMLDocument, (void**)&doc);
if (idisp && !doc2) idisp->QueryInterface(IID_IHTMLDocument2, (void**)&doc2);
if (doc2 && !win2) doc2->get_parentWindow(&win2);
IConnectionPointContainer *cpc=0; if (doc) doc->QueryInterface(IID_IConnectionPointContainer, (void**) &cpc);
IConnectionPoint* cp=0; if (cpc) cpc->FindConnectionPoint(DIID_HTMLDocumentEvents2, &cp);
DWORD cookie; HRESULT hr; if (cp) hr=cp->Advise(static_cast<IDispatch*>(this), &cookie);
if (cp) cp->Release(); if (cpc) cpc->Release(); if (idisp) idisp->Release();
if (!doc || !doc2 || !win2 || hr!=S_OK) {release(); return E_FAIL;}
return NOERROR;
------解决方案--------------------------------------------------------
没人会吧。 这个才比较正常。