Sign in to follow this  
blaze02

C++: Create a Popup

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this