Thread: How to detect and open the default browser

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    79

    How to detect and open the default browser

    Hi. I would like to open the default internet browser from within my c++ program, and it should open directly with a specified URL. Does anyone have any idea how I can do it?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    There are a few ways of doing it (A thread recently covered this and some of the methods included ATL and the like)....It can be tedios to find the default browser....where it is kept on disk....open it and get it to open a page............but the easiest way is to trust the shell to do the work for you.....

    Look up ShellExecute() on MSDN......the file to open needs to be the full URL (ala..."http://www.cprogramming.com")

    The shell will look at the use settings, see which browser is the default browser, open the app and open the webpage (basically the shell will do all the work for you.....and you dont need to lookup the user's preferences.....that's what the shell is there for I guess!)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Edge Detect
    By 250co in forum C Programming
    Replies: 0
    Last Post: 05-22-2006, 08:51 PM
  2. Detecting if a program is open
    By nate11000 in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2003, 08:22 PM