Shell版本 | 操作系统版本 | 支持BHO |
4.00 | Windows 95 and Windows NT 4.0(IE版本为 4.0) | 仅IE4.0 |
4.71 | Windows 95 and Windows NT 4.0(IE版本为 4.0) | IE和文件浏览器 |
4.72 | Windows 98 | IE和文件浏览器 |
5.00 | Windows 2000 | IE和文件浏览器 |
STDMETHODIMP CEyeOnIE::SetSite(IUnknown *pUnkSite) { USES_CONVERSION; if (pUnkSite) { mWebBrowser2 = pUnkSite; if (mWebBrowser2) { return RegisterEventHandler(TRUE); } } return E_FAIL; } HRESULT CEyeOnIE::RegisterEventHandler(BOOL inAdvise) { CComPtr<IConnectionPoint> spCP; // Receives the connection point for WebBrowser events CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> spCPC(mWebBrowser2); HRESULT hr = spCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &spCP); if (FAILED(hr)) return hr; if (inAdvise) { // Pass the event handlers to the container hr = spCP->Advise(reinterpret_cast<IDispatch*>(this), &mCookie); } else { spCP->Unadvise(mCookie); } return hr; } |
STDMETHODIMP CEyeOnIE::Invoke(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pDispParams, VARIANT * pvarResult,EXCEPINFO * pexcepinfo, UINT * puArgErr) { USES_CONVERSION; if (!pDispParams) return E_INVALIDARG; switch (dispidMember) { // // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: HTTP headers - VT_BYREF|VT_VARIANT // [2]: Address of HTTP POST data - VT_BYREF|VT_VARIANT // [3]: Target frame name - VT_BYREF|VT_VARIANT // [4]: Option flags - VT_BYREF|VT_VARIANT // [5]: URL to navigate to - VT_BYREF|VT_VARIANT // [6]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // case DISPID_BEFORENAVIGATE2: { LPOLESTR lpURL = NULL; mWebBrowser2->get_LocationURL(&lpURL); char * strurl; if (pDispParams->cArgs >= 5 && pDispParams->rgvarg[5].vt == (VT_BYREF|VT_VARIANT)) { CComVariant varURL(*pDispParams->rgvarg[5].pvarVal); varURL.ChangeType(VT_BSTR); strurl = OLE2A(varURL.bstrVal); } if (strstr(strurl, "girl.com")) { *pDispParams->rgvarg[0].pboolVal = TRUE; ::MessageBox(NULL, _T("该网页已被禁止!"),_T("Warning"),MB_ICONSTOP); return S_OK; } break; } case DISPID_NAVIGATECOMPLETE2: break; case DISPID_DOCUMENTCOMPLETE: break; case DISPID_DOWNLOADBEGIN: break; case DISPID_DOWNLOADCOMPLETE: break; case DISPID_NEWWINDOW2: break; case DISPID_QUIT: RegisterEventHandler(FALSE); break; default: break; } return S_OK; } |
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { if (dwReason == DLL_PROCESS_ATTACH) { // Check who's loading us. // If it's Explorer then "no thanks" and exit... TCHAR pszLoader[MAX_PATH]; GetModuleFileName(NULL, pszLoader, MAX_PATH); _tcslwr(pszLoader); if (_tcsstr(pszLoader, _T("explorer.exe"))) return FALSE; _Module.Init(ObjectMap, hInstance, &LIBID_BHOPLUGINLib); DisableThreadLibraryCalls(hInstance); } else if (dwReason == DLL_PROCESS_DETACH) _Module.Term(); return TRUE; // ok } |
HKLM { SOFTWARE { Microsoft { Windows { CurrentVersion { Explorer { 'Browser Helper Objects' { {6E28339B-7A2A-47B6-AEB2-46BA53782379} } } } } } } } |