分类:
2007-03-07 14:35:27
Article ID | : | 255920 |
Last Review | : | July 15, 2004 |
Revision | : | 2.3 |
STDMETHODIMP CShowBarObj::SetSite(IUnknown *pUnkSite)
{
if (NULL != pUnkSite)
{
IWebBrowser2 *pBrowser = NULL;
// Ensure that our site is an browser window
HRESULT hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void **) &pBrowser);
if (SUCCEEDED(hr))
{
// Display the band object (the Search bar in this case)
VARIANT vtBandGUID, vtShow;
vtBandGUID.vt = VT_BSTR;
vtBandGUID.bstrVal = SysAllocString(OLESTR("{30D02401-6A81-11D0-8274-00C04FD5AE38}"));
vtShow.vt = VT_BOOL;
vtShow.boolVal = true;
pBrowser->ShowBrowserBar(&vtBandGUID, &vtShow, 0);
SysFreeString(vtBandGUID.bstrVal);
pBrowser->Release();
}
}
return S_OK;
}
Also, you must include the header file ExDisp.h in the code and append the following code to the RGS file used for DLL self-registration. Note that you must replace "{77D54ACE-09A9-11D4-8ACE-00C04F542830}" with the CLSID of your BHO: HKLM {
SOFTWARE {
Microsoft {
Windows {
CurrentVersion {
Explorer {
'Browser Helper Objects' {
{77D54ACE-09A9-11D4-8ACE-00C04F542830}
}
}
}
}
}
}
}