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.
Printable View
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.
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.
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)
Thanks. I hope it will work.
Zulfi
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.
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: [email protected]
MIT Sloan Tel: (781) 767-0417
__________________________________________