0
votes

I need to open a webpage using Internet Explorer even if it is not the predefined Browser.

(e.g. Chrome is predefined but I want to open www.ThisRunsOnlyOnInternetExplorer.com.

How to achieve this? Of course with ShellExecute I know how to open the default browser.

Of course this must work on all Windows operating systems and all internet explorer versions so I cannot harcode a path to iexplorer.exe.

Can you suggest a solution?

Note: if there is a way to get the path to iexplorer.exe with some API may be the trick is gtet that path and then use ShellExecute to run

PATH_TO_INTERNET_EXPLORER_EXE www.ThisRunsOnlyOnInternetExplorer.com
3
Isn't iexplore.exe on the path in every Windows version? Then you can just use ShellExecute iexplore www.ThisRunsOnlyOnInternetExplorer.com.Matthijs Bierman
In my Windows 7 machine it is not on the pathLaBracca
@Matthijs you were right anyway David clearified my problemLaBracca
Without disputing your need to do this, since you don't mention the details, please know that this is going to be quite annoying for some of your users. People choose their browser for a reason, and whenever you override their choice, you increase their adrenaline flow and add to their daily stress level. Please be aware of that, seriously.Marek Jedliński

3 Answers

5
votes

You don't need to use a fully qualified path. When IE is installed it registers itself in the App Paths registry. Consequently you just need to send iexplore.exe to ShellExecute().

Note: CreateProcess() does not use the App Paths mechanism so you must use ShellExecute() rather than CreateProcess().

1
votes

try something like ShellExecute(handle, "open", "%PROGRAMFILES%\Internet Explorer\iexplore.exe", "http://google.com", NULL, SW_SHOWNORMAL);

I think programfiles is set for all windows.

EDIT: I deleted the other stuff, because I didn't quite get the question.

1
votes

I use to have the same problem as you. I have Google Chrome as my defaut browser and want to force using IE for some specific URL. I found a solution that work perfectly for me. I use ShellExecuteEx and I specify the file type as a IE.HTTP or IE.HTTPS.

I hope it help.

FillMemory(@vShellExec, SizeOf(TShellExecuteInfo), 0);
vShellExec.cbSize := SizeOf(vShellExec);
vShellExec.fMask := SEE_MASK_CLASSNAME or SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_NO_UI;
vShellExec.Wnd := 0;
vShellExec.lpFile := PChar(asURL);
vShellExec.nShow := SW_ShowNormal;
vShellExec.lpClass := PChar(sFileType); // use IE.HTTP or IE.HTTPS
vShellExec.lpVerb := PChar('Open');

ShellExecuteEx(@vShellExec);