Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ShellExecute to launch a Web Browser

Posted on 1998-03-26
5
Medium Priority
?
539 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 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