Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

ShellExecute to launch a Web Browser

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
gunn
Asked:
gunn
  • 3
  • 2
1 Solution
 
chensuCommented:
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
 
gunnAuthor Commented:
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
 
chensuCommented:
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
 
chensuCommented:
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
 
gunnAuthor Commented:
Hmmmm, ok! Thanks a lot, I'll give this a shot ;)

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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