ShellExecute Help

Is there a way to open a website in a new window for chrome or firefox? I tried this:

 
ShellExecute(NULL, "open", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "www.google.com", NULL, SW_SHOW);

but that didn't work. If it isn't possible to do that, is there a way to just switch between tabs?
Last edited on
To open a website with the default browser action, use

1
2
3
4
5
HINSTANCE err = ShellExecuteA( NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL );
if ((long long)err <= 32)
{
  std::cout << "fooey!\n";
}

Check the result to see what wrong (if anything).

Hope this helps.
There isn't an error. It just opens in the current window that is open. I want it to open a website into a new window. Or just a way to switch between tabs, which I don't know if that's possible or not.
Oh, I understand.

The way things are designed it isn't very easy to hijack the user's preferences and open a new window. Letting the user's running browser decide how to do it is the way it should work.

Anything beyond that is playing in no-man's land. If you wish to target specific browsers you can use extant command-line options:

https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options
 
ShellExecuteA( NULL, "open", verified_path_to_firefox, "-new-instance http://www.google.com", NULL, SW_SHOWNORMAL );

http://peter.sh/experiments/chromium-command-line-switches/
 
ShellExecuteA( NULL, "open", verified_path_to_chrome, "--new-window http://www.google.com", NULL, SW_SHOWNORMAL );

Etc. You'll have to look up other browsers yourself, and consider the possibility that your user may not have a browser you know about except IE.

Hope this helps.
Last edited on
Ok that works. Thanks for the help
Topic archived. No new replies allowed.