I have a code that is opening a browserwindow like this:

Process::Start("iexplore.exe", "http://www.google.com"); //Open google in a defaultBrowser

I wonder something about this "iexplore.exe".

I am not sure what that meens. Does it meen that it Only will open Internet Explorer if that exists on the users computer.
What will happen if the users doesn´t have Internet Explorer but instead FireFox or Opera or something else.

If that is the case, I might wonder if there are any more portable code to open a browser for the browserapplication that does exist on the users computer ?

Thank you

All MS-Windows computers have IE -- at least in USA. I've heard there have been some lawsuits about that around the world but I don't know the outcome. HINSTANCE hInstance = ShellExecute(NULL, "open", "www.google.com", NULL, NULL, SW_SHOW); The above will use the default browser, whatever that is.

Thanks for that, I am happy that there this command exists. I use managed C++.
I have problem to compile the line though.
When trying to comple this, I get these errors:

HINSTANCE undeclared identifier
syntax error missing ";" before identifier "hInstance
SW_WHOW undeclared identifier
ShellExecute identifier not found

HINSTANCE hInstance = ShellExecute(NULL, "open", "www.google.com", NULL, NULL, SW_SHOW);

//I have also tried this
//HINSTANCE^ hInstance = ShellExecute(nullptr, "open", "www.google.com", nullptr, nullptr, SW_SHOW);

All MS-Windows computers have IE -- at least in USA. I've heard there have been some lawsuits about that around the world but I don't know the outcome. HINSTANCE hInstance = ShellExecute(NULL, "open", "www.google.com", NULL, NULL, SW_SHOW); The above will use the default browser, whatever that is.

Edited 6 Years Ago by Lukezzz: n/a

I am not sure but the code seems a bit messy and not exactly targeted to the managed framework.

I have tested this out. This does open my Internet explorer browser with www.google.com and what I wonder is if this code identifies what browser that is installed and is used as the default browser as the browser isn´t specified here ?
I have 6 different browsers installed on my computer and uses Internet Explorer 8 as my default.

This code does open Internet Explorer 8 in this case.
Is this portable and will open a users default browser whatever that could be ?

Process::Start("http://www.google.com");

The default browser is a registry entry. So when ShellExecute() (or some other function) runs it checks the registry to find out what browser to use. If you open another browser on your computer and set it to be the default, then run your program you should find that the new default browser will be used to open google.com.

Edited 6 Years Ago by Ancient Dragon: n/a

I understand, it looks for the registry, it seems logical.

I tried to use this by setting Safari as a defaultbrowser but then this command does not work:
Process:: Start("http://www.google.com");

I have now tried both these lines below one at a time but get ca 100 lines of compileerrors where these are constantly repeating:
Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(4389) : error C2872: 'FILETIME' : ambiguous symbol
Program Files\Microsoft SDKs\Windows\v6.0A\include\windef.h(377) : _FILETIME FILETIME'
windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::FILETIME'
Microsoft SDKs\Windows\v6.0A\include\objidl.h(12671) : error C2872: 'IDataObject' : ambiguous symbol
windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IDataObject'

I use managed C++ and are not sure if any of these lines works here or what I should do ?

#include <windows.h>

HINSTANCE hInstance = ShellExecute(NULL, "open", "www.google.com", NULL, NULL, SW_SHOW); 
HINSTANCE^ hInstance = ShellExecute(nullptr, "open", "www.google.com", nullptr, nullptr, SW_SHOW);

Edited 6 Years Ago by Lukezzz: n/a

I googled and found this example here.

I have tried to set IE8, FireFox and Chrome as default browsers and this command actually works here.

This might be quite portable ?

Help::ShowHelp(this, "http://www.google.com");
This article has been dead for over six months. Start a new discussion instead.