开发者

VC++ ShowBrowserBar doesn't work on IE8

开发者 https://www.devze.com 2023-01-06 21:50 出处:网络
When I run this code on IE8, ShowBrowserBar returns S_OK, but the toolbar isn\'t shown. On IE7 it works fine.

When I run this code on IE8, ShowBrowserBar returns S_OK, but the toolbar isn't shown. On IE7 it works fine. I saw a similar question here, by Anna, but without a working answer... :) Any suggestions?

int _tmain(int argc, _TCHAR* argv[])
{
   CoInitialize(0);
   IWebBrowser2 *pIE = NULL;

   // Create an instance of Internet Explorer
   HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER,       IID_IW开发者_高级运维ebBrowser2, (void**)&pIE);
   if (FAILED(hr)) {
      return 1;
   }

   if( pIE != NULL ) {
      VARIANT vtBandGUID, vtShow, vtSize;
      vtBandGUID.vt = VT_BSTR;
      vtBandGUID.bstrVal = SysAllocString( L"{my-toolbar-guid}" );

      vtShow.vt = VT_BOOL;
      vtShow.boolVal = VARIANT_TRUE;
      vtSize.vt = VT_I2;
      vtSize.iVal = 0;

      HRESULT hr = pIE->ShowBrowserBar( &vtBandGUID, &vtShow, &vtSize );
      SysFreeString( vtBandGUID.bstrVal );
      pIE->Release();
   }
   CoUninitialize();
   return 0;
}


By default, any add-on or toolbar you install in Internet Explorer will be enabled; but it can later on become disabled  (you can no longer use it), either because you or another Windows user has manually disabled it, or because a third-party installer in conflict automatically disabled it. If user disable toolbar manually you can't show it automatically! You need to re-enable the add-on, in Tools, Manage Add-Ons.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号