make a program open a webpage?

how exactly would you make a program open a website?
Last edited on
I don't know if it's the best way but you can do it using CreateProcess()
how exactly do i use that? also any other suggestions?
What do you mean by "open a website"? Be precise with what you want to accomplish.

Do you want some hypothetical stream like this?

1
2
3
4
5
6
std::string data;
ihttpstream url("http://www.cplusplus.com/");
while (getline(url, data))
{
    ...
}
pretty much i want it so that if a certain condition is met it opens firefox(or the default web browser) and goes to a certain website. all I really need to know though is how to make it open firefox and make it go directly to a specific website
Forking off an external application is OS-specific. What operating systems does this need to work with?
windows or linux but preferably windows
There is also the very friendly ShellExecute() function in Windows, which will use the user's default web browser to open the URL you specify:
1
2
3
4
5
6
7
8
#include <shellapi.h>

...

if (ShellExecute( NULL, TEXT( "open" ), TEXT( "http://www.cplusplus.com/" ), NULL, NULL, 0 ) <= 32)
  {
  cout << "I could not open cplusplus.com!\n";
  }

The result of the function is useless except to tell whether or not it succeeded. If you want a handle to the process created/used to display your website you will need to use the ShellExecuteEx() function.

http://www.google.com/search?btnI=1&q=msdn+ShellExecute
http://www.google.com/search?btnI=1&q=msdn+ShellExecuteEx

Hope this helps.
Topic archived. No new replies allowed.