How to call IE to open an HTML file from a C program ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a user manual for my program in HTML format, and I want to open it
from my program by clicking a button.

How can I call the IE with my HTML file inside my program ?

Thanks,

Elga.
 
Elga said:
I have a user manual for my program in HTML format, and I want to open it
from my program by clicking a button.

How can I call the IE with my HTML file inside my program ?

I see that Jochen has already pointed you to the simplest solution.

If you need more control over the broswer you could use the ugly hack below
as a starting point to get up to speed on the browser object. My hack
demonstrates how to hide the address bar in the browser as an example.

Regards,
Will

#include <windows.h>
#include <exdisp.h>

int main()
{
BSTR bstrURL;
HRESULT hr;
VARIANT v;
VARIANT_BOOL vb;
IWebBrowser2 *pBrowser ;

hr = CoInitialize(NULL);

if ( SUCCEEDED(hr) )
{
hr = CoCreateInstance (CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (LPVOID *)&pBrowser);

if ( SUCCEEDED(hr) )
{
vb = FALSE;
pBrowser->put_AddressBar(vb);

bstrURL = SysAllocString(L"C:\\Readme.html");
v.vt = VT_EMPTY;
pBrowser->Navigate(bstrURL, &v, &v, &v, &v);
SysFreeString(bstrURL);

vb = TRUE;
pBrowser->put_Visible(vb);
}

CoUninitialize();
}

return 0;
}
 
Back
Top