Jump to content
  • Advertisement
Sign in to follow this  
blaze02

C++: Create a Popup

This topic is 4454 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

What can I write inside of the main() that will pop-up a webpage in an external browser? So I need to create a thread running the default browser and open up a certain webpage... I've tried
system("http://www.blah.com")
I thought this would work. It spawns and quickly closes a DOS box. The system function should tell the OS to open that webpage, and that should spawn the default browser... is that not right? I suppose the other option would be to
WinExec("...iexplorer[firefox].exe http://www.blah.com");
What is the best option? It seems the system function should do exactly what I want, right? Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
I originally saw something about ShellExecute, but disregarded it for some reason or another. It worked great, thanks.

Share this post


Link to post
Share on other sites
system("start http://www.blah.com") would work too, though ShellExecute is definately the preferred way.

Share this post


Link to post
Share on other sites
Quote:
Original post by blaze02
What can I write inside of the main() that will pop-up a webpage in an external browser?

So I need to create a thread running the default browser and open up a certain webpage... I've tried

system("http://www.blah.com")

I thought this would work. It spawns and quickly closes a DOS box. The system function should tell the OS to open that webpage, and that should spawn the default browser... is that not right?


No. system() simply sends a command to the OS directly, assuming it has a facility for understanding text commands (good luck on Mac OS pre OS X, for example), and the URL itself is not a command:


C:\Documents and Settings\some body>http://www.blah.com
'http:' is not recognized as an internal or external command,
operable program or batch file.


As noted, start http://www.blah.com should work. 'start' is a program with a bit of intelligence to it; it reads its command line arguments, and can recognize (for example) URLs as bits of data that it should handle by launching the system's default web browser and pointing it at that URL.

But seriously, if this sort of thing is the primary purpose of your "program", you *don't* want to do it in C++. Use the right tool for the job: a script language like .bat (or even Python or Perl).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!