tags:

views:

522

answers:

0

I am trying to create an mshtml document object from an html buffer. But when the following code is executed it is invoking internet explorer window. How do I prevent it invoking IE.

#include <atlbase.h>
#include <mshtml.h>


CoInitialize(NULL);

CString strHTMLCode = _T("<html><head><script language=\"JavaScript\">{top.location.href=\"index.php\"}</script></head><body></body></html>");

CComPtr<IHTMLDocument2> pDoc;
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (void**)&pDoc);

SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;

hr = SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = strHTMLCode.AllocSysString();

hr = pDoc->write(psa); //This line invoks internet explorer window.
hr = pDoc->close();