Skip to main content
gamedev.net
🔒 Locked

Launching a site from within program

Started by Ganoosh_ Sep 22, 2006 at 3:28 PM 2 replies 500+ views
Original Post
Ganoosh_
Ganoosh_
Using C++ on Windows, trying to make a button that will launch my site when clicked. I know how to launch programs, but how would I make it launch the default browser on the user's computer, rather than just hardcoding it for IE or Firefox. Is there a system variable maybe? Also, how do I pass the URL to the browser so it opens the designated site? Thanks in advance
dave
dave
I'm not sure about finding the default browser but my best guess would be that it is stored as a registry key. To get the browser to open a url, pass it on the command line.

Dave
Excors
Excors
You could see how wxWidgets does it in wxLaunchDefaultBrowser - in the case where it's on Windows and it doesn't have to be a new browser window, it looks like it's basically doing
    SHELLEXECUTEINFO sei;    ::ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));    sei.cbSize = sizeof(SHELLEXECUTEINFO);    sei.lpFile = url.c_str();    sei.lpVerb = _T("open");    sei.nShow = SW_SHOWNORMAL;    ::ShellExecuteEx(&sei);
Mike.Popoloski
Mike.Popoloski
Yes, ShellExecute is your friend. You can use it to perform actions that are normally accessed by right clicking on an icon on the desktop. You don't have to use the Ex version, which is a little more complicated. Instead, just do something like this:

ShellExecute( NULL, NULL, "http://www.mysite.com", NULL, NULL, SW_SHOW );
Mike Popoloski | Journal | SlimDX

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.