Jump to content
  • Advertisement
Sign in to follow this  
silverphyre673

Launch browser from within program

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there an easy way to lauch a browser window and direct it automatically to a certain webpage? In the game I just made, I would like to be able to make a button that directs users to my website when clicked. I'm using Windows, and the program is written in C++, using SDL. Thanks!+

Share this post


Link to post
Share on other sites
Advertisement
In windows you can do this:

system("iexplore http://www.hotmail.com");

for example.

Not the best way im sure but it is easy.

ace

Share this post


Link to post
Share on other sites
You may want to try the ShellExecute() function instead. It should use the user's default web browser.

Share this post


Link to post
Share on other sites
Thought there would be a better way. Is that including windows.h as well si?

And also presumably the same command as i suggested?

ace

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How do you call the default browser? You can tell either Valve doesn't care about it's users defaults or is in bed with Microsoft as Steam upon updates launches IE whenever you click on a link. It's truely annoying. I don't use IE for a reason, I dislike people making decisions for me and for the safety of my PC.

Share this post


Link to post
Share on other sites
There is probably a registry key that defines the path of the default browser.

ace

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well aware of that feature Vampyre_Dark, but how do you do that with ShellExecute() or system()? :) I tried system and you need more then just the URL (knew it but had to test it). Now I was working with a console app and I'm on my way out the door so I don't have time to load up my windows test app and toss in ShellExecute to try it...

I've been wondering about this myself, I had code awhile ago that let you add URLs into dialog boxes but I cannot find it, as I'm sure it had a solution in it.

Share this post


Link to post
Share on other sites
ShellExecute is in shellapi.h and will call the default browser.

The default browser is "defined" in HKEY_CLASSES_ROOT under the extension for web files. It will typically be "redirected" from HKR\.htm or HKR\.html to HKEY_CLASSES_ROOT\htmlfiles.

edit: This is how you would use it:
ShellExecute( NULL, "open", "Web page.htm", NULL, NULL, SW_SHOW );


edit2: Some systems will have the "open" verb not be the default verb, so you can use NULL instead of "open", which will call the default action.


jfl.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://msdn.microsoft.com/msdnmag/issues/05/03/CATWork/

Answered my own question. ShellExecute with just the URL should launch the default browser. I'll confirm later and post if it doesn't.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!