Reputation: 56
I am creating toolbar usign the BHO.And in that I want to modify the user agent string in IE as follow:
current string : Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)
Require string : CustomName, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)
Here I want to add custom Name before the Mozilla/4.0 text. So how can I do it? What changes I need to make in the registry "User Agent" key or I need to make changes in some other registry key?
Thanks,
Upvotes: 0
Views: 1248
Reputation: 365
In your dialog/window that hosts the web browser (IWebBrowser2/CWebBrowser2/etc) you just need to override OnAmbientProperty. It is a virtual method part of CWnd.
BOOL CMyLoginDlg::OnAmbientProperty(COleControlSite* pSite, DISPID dispid,
VARIANT* pvar)
{
if (dispid == DISPID_AMBIENT_USERAGENT)
{
CString strUserAgent("CustomName, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
pvar->vt = VT_BSTR;
pvar->bstrVal = strUserAgent.AllocSysString();
return TRUE;
}
return __super::OnAmbientProperty(pSite, dispid, pvar);
}
That should do it!
Upvotes: 0
Reputation: 70369
The easiest option would be via registry - see for details http://msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspx#UARegistry
Upvotes: 2