UnDiUdin
UnDiUdin

Reputation: 15384

Force opening a webpage with Internet Explorer

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

Upvotes: 0

Views: 6189

Answers (3)

Pierre-Luc Arguin
Pierre-Luc Arguin

Reputation: 11

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

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 612954

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().

Upvotes: 5

craniumonempty
craniumonempty

Reputation: 3535

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.

Upvotes: 1

Related Questions