Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

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

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
Conwood
Asked:
Conwood
  • 2
  • 2
  • 2
  • +2
1 Solution
 
SChertkovCommented:
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
 
BeyondWuCommented:
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
 
SChertkovCommented:
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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
Jenn050402Commented:
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
 
BeyondWuCommented:
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
 
ConwoodAuthor Commented:
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
 
Jenn050402Commented:
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
 
Computer101Commented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now