Solved

Add a button to IE's Toolbar to navigate http://somewhere?

Posted on 2002-07-22
8
287 Views
Last Modified: 2013-12-03
After i installed some software,it can add a button to IE's standard button bar.Once i click the button ,my IE would go to the software's homepage.

I searched in Regedit,i found this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Extensions

Now i can add a button to run a EXE file,but how to let it navigate a specified URL,such as http://www.yahoo.com?

Thanks!
0
Comment
Question by:Conwood
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 2

Expert Comment

by:SChertkov
ID: 7171028
You must create small COM object that implements
interface  IOleCommandTarget (and optionally IObjectWithSite for access to DHTML) and register
it in HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Extensions\

For details referer to MSDN for additional details

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/tutorials/button.asp

0
 
LVL 9

Accepted Solution

by:
BeyondWu earned 100 total points
ID: 7173604
To do this, you need to implement IObjectWithSite interface. In the IObjectWithSite::SetSite(IUnknown* pUnkSite), IE will input an interface, you can get IWebBrowser2 from this interface, then call IWebBrowser2::Navigate(URL,...
#include <atlbase.h>
CYourExplorerButton::SetSite(IUnknown* punkSite)
{
   CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> spWebBrowser2;
   // Query pUnkSite for the IWebBrowser2 interface.
   m_spWebBrowser2 = pUnkSite;

   // navigate to any URL
   CComBSTR bstrURL(szURL);
   CComVariant vtEmpty;

   spWebBrowser2->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);
   // ...
}
0
 
LVL 2

Expert Comment

by:SChertkov
ID: 7173639
You code will navigate to URL every time when call
IObjectWithSite::SetSite from browser. I think every time
when browser open.

spWebBrowser2->Navigate must calling in
IOleCommandTarget::Exec
0
 
LVL 1

Expert Comment

by:Jenn050402
ID: 7174381
Conwood,
See if this helps...

See this site for how IE's toolbar buttons are constructed and behave:
http://msdn.microsoft.com/workshop/browser/ext/tutorials/button.asp
http://msdn.microsoft.com/workshop/browser/ext/overview/toolbar_style.asp

Jenn

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:BeyondWu
ID: 7176016
SChertkov, you are right,
Conwood, I made a mistake.
At the CYourExplorerButton::SetSite(IUnknown* punkSite), you should save the IWebBrowser2 interface, and in IOleCommandTarget::Exec, you can call spWebBrowser2->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);

#include <atlbase.h>
// please add the spWebBrowser2 into your class as a data member.
// so just as a global variable.
CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> spWebBrowser2;

CYourExplorerButton::SetSite(IUnknown* punkSite)
{
  // Query pUnkSite for the IWebBrowser2 interface.
  // and save it.
  m_spWebBrowser2 = pUnkSite;
  // ...
}

CYourExplorerButton::Exec(...)
{
  // navigate to any URL
  CComBSTR bstrURL(szURL);
  CComVariant vtEmpty;

  spWebBrowser2->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);
  // ...
}


0
 

Author Comment

by:Conwood
ID: 7176039
Thanks all.
I'm busy with exams these days , so perhaps I have to try your method some days later.

Another question:how I can i give 200 marks to you three?
I mean , for example : give one 100 , another 50 , another 50.
0
 
LVL 1

Expert Comment

by:Jenn050402
ID: 7177585
You can post a message in community support saying you want your points refunded because you want to split them.
Then post a "points for ..." question in the Windows Programming area for the users you want the points to go to worth how many points you want to give each. When the user posts an answer (just something saying "thanks for the points..." you accept answer.

 
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7183369
Points have been reduced to 100 and the remaining 100 refunded to you.  Now you can accept a comment from one expert.  After that, make another question in this topic area for the other expert.

Compmuter101
E-E Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now