1
General Software Discussion / Re: ChameleonNavigator
« on: June 16, 2006, 02:44 AM »
I'm using BeforeNavigate2. I hope it helps you:
Code: C++ [Select]
- void CMyView::BeforeNavigate2(LPDISPATCH pDisp, VARIANT* URL,
- VARIANT* Flags, VARIANT* TargetFrameName,
- VARIANT* PostData, VARIANT* Headers, VARIANT_BOOL* Cancel)
- {
- IWebBrowser2* pWB = NULL;
- HRESULT hr = pDisp->QueryInterface( IID_IWebBrowser2, (void**)&pWB );
- if(SUCCEEDED(hr))
- {
- CString csHeaders(V_BSTR(Headers));
- CString csURL(V_BSTR(URL));
- if(csHeaders.Find("User-Agent")==-1 && csURL.Find("about:blank")==-1)
- {
- pWB->Stop();
- CString strHeader = "" ;
- strHeader += "User-Agent:";
- strHeader += "HERE MY NAME";
- strHeader += "\r\n";
- COleVariant vHeaders(_T(strHeader), VT_BSTR );
- pWB->Navigate2(URL, Flags, NULL, PostData, vHeaders);
- }
- else
- {
- CHtmlView::BeforeNavigate2(pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel);
- }
- pWB->Release();
- }
- }