I’m writing a BHO (Browser Helper Object) that catches the address the user enters checks it and the depending on the result performs a cretin operation.
The BHO hooks into the browser events and then i catch the DISPID_BEFORENAVIGATE2 event and do my stuff.
My problem is that our users all have a internal proxy server that will sometimes block sites when this happens the address i get in the DISPID_BEFORENAVIGATE2 event is the address the proxy returned, when the address i really need is the one the user typed in.
Anyone know how I can catch the address before I’m referred to the proxy?
I found the solution to this. I was getting the URL from the browser object so what I was actually getting was the page displayed ans since the proxy message was a redirect it was never displayed so I never saw it.
I have now switched to getting the URL from the DISPID_BEFORENAVIGATE2 parameters:
LPTSTR CBhoApp::varToStr(VARIANT var)
{
USES_CONVERSION;
if(var.vt == VT_BSTR)
{
LPTSTR psz = new TCHAR[SysStringLen(var.bstrVal)];
lstrcpy(psz, OLE2T(var.bstrVal));
return psz;
}
else
return NULL;
}
STDMETHODIMP CBhoApp::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pvarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
BSTR bstrUrlName;
LPTSTR psz;
if(dispidMember == DISPID_BEFORENAVIGATE2)
{
//This is the parameter for the URL.
VARIANT* tmp = pDispParams->rgvarg[5].pvarVal;
psz = varToStr(*tmp);
.
.
.
}
}