Solved

ShellExecute to launch a Web Browser

Posted on 1998-03-26
5
526 Views
Last Modified: 2013-12-03
I'm using ShellExecute() to load the users default browser when the user chooses to view my help file system in my application.Currently, I pass in the name of the file to launch into the browser, but thats not quite as well as I would like it. In addition to loading the html file, I'd also like it to go to a specific anchor; ie: sample.html
0
Comment
Question by:gunn
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1412303
Use FindExecutable() function to get the exe full path name of the default browser. Then, you can use ShellExecute() to specify the exe and the HTML filename with #Anchor as the parameter.

For example, the parameters for ShellExecute(),

lpFile: "C:\Program Files\Internet Explorer\Iexplore.exe"  found by FindExecutable().
lpParameters: "C:\INetSDK\Help\inet0257.htm#ratings_040f000103000000".
0
 

Author Comment

by:gunn
ID: 1412304
Thanks a lot, that worked. I hope you can add a comment here for a problem that I found due to this result though...



When I pick the help from the menu the first time, it loads the browser and page at the right anchor. However, if I go through my application, say to another window and choose help on that window  (a new page and new anchor), I get a brand new browser to launch with this info. So now I have 2 browsers open. I'd like for it to load the new page into the already opened browser...and I can't figure out how to do this?



Thanks again for the help
0
 
LVL 23

Expert Comment

by:chensu
ID: 1412305
I cannot think of an easy way to do so. Take a look at the following Microsoft KB articles:
Article ID: Q160976  HOWTO: Controlling the Currently Running Instance of IE3 via DDE
Article ID: Q176792  HOWTO: Connecting to a Running Instance of Internet Explorer
0
 
LVL 23

Expert Comment

by:chensu
ID: 1412306
I have just thought of an easy way to do so. You can create a temporary URL shortcut containing the URL with an anchor and use ShellExecute to execute the shortcut. This might work. A URL shortcut is simply a text file like the following:

[InternetShortcut]
URL=http://www.experts-exchange.com/Q.10044944#anchor

0
 

Author Comment

by:gunn
ID: 1412307
Hmmmm, ok! Thanks a lot, I'll give this a shot ;)

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…

809 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