Click to See Complete Forum and Search --> : Invoke IE from VC++


Zulfi Khan
April 15th, 1999, 01:10 AM
How I can load a HTML file from a Visual C++ program? I want to load that file into Internet Explorer. I have Visual C++ 5 Enterprise Version for Win95, Internet Explorer 3.0.

April 15th, 1999, 02:01 AM
Try using ShellExecute:

CString sFile="c:\\my.html";// your html file path goes here
HINSTANCE h = ShellExecute(NULL, "open", sFile, NULL, NULL, SW_SHOWNORMAL);

I think that will work as long as IE is registered as the app for HTML files.
If not it would find whichever browser the user has made default.

Thomas Atwood
April 15th, 1999, 02:21 AM
simply add this command to your code:
ShellExecute(NULL,"open",URL,NULL,NULL,SW_SHOWNORMAL);

(where URL is a string containing the HTML URL or file name to load)

Zulfi Khan
April 15th, 1999, 04:27 AM
Thanks. I hope it will work.
Zulfi

Fabrice
April 26th, 1999, 04:55 AM
You should also "insert a IE ActiveX control" in a dialog box of your VC++ applications.
Then "Add a member variable" on this control.
And then call the following code:
m_WebBrowser.Navigate( m_strURL, NULL, NULL, NULL, NULL);
where m_WebBrowser is the member variable of the IE ActiveX object and m_strURL is your URL.

May 11th, 1999, 12:45 PM
On most systems (at least mine) the running ShellExecute with the URL as a parameter activates the most recently launched instance of IE and opens the URL in it. To open a NEW instance of IE, do this:

ShellExecute(AfxGetApp()->GetMainWnd()->m_hWnd, NULL, "C:\\Program Files\\Plus!\\Microsoft Internet\\IEXPLORE.EXE", "http://www.codeguru.com", NULL, SW_SHOWNORMAL);

This runs IE and sends the URL as a parameter. I assume something similar would work with Netscape.


__________________________________________

_=====_ Espen Zachrisen
========= Sloan School of Management
||||||||| MBA Class of 2000
========= Email: ezachris@mit.edu
MIT Sloan Tel: (781) 767-0417
__________________________________________