承接各种BHO,ActiveX,chrome扩展插件开发,微信showcodehr

1.VS2005 + IE8无法调试

因为IE8是多线程的。按照tab调试(原因百度)

打开: HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer/Main

添加一个新DWORD键值TabProcGrowth,并且把值设为0.

URL劫持,重定向

void STDMETHODCALLTYPE CSevenFanliBHO::OnBeforeNavigate2(IDispatch* pDisp, VARIANT* URL, VARIANT* pvtFlags, VARIANT* pvtTargetFrameName, 
VARIANT* pvtPostData, VARIANT* pvtHeaders, VARIANT_BOOL* pvbCancel)
{
if (0 == ::wcscmp(URL->bstrVal, L"https://www.baidu.com/"))
{
//*pvbCancel = VARIANT_TRUE;
VARIANT varNewUrl;
varNewUrl.vt = VT_BSTR;
varNewUrl.bstrVal = ::SysAllocString(L"https://www.hao123.com/");
IWebBrowser2* pWB2;
pDisp->QueryInterface(IID_IWebBrowser2, (void**)&pWB2);
pWB2->Stop();//此句可有可无
pWB2->Navigate2(&varNewUrl, pvtFlags, pvtTargetFrameName, pvtPostData, pvtHeaders);
::SysFreeString(varNewUrl.bstrVal);
}
}