Big difference between VB new operator and COM CoCreateInstance?
-
I want to convert HTML to TEXT from some string It good works in VB code like this: Dim body As String Dim hd As HTMLDocument Dim str As String Set hd = New HTMLDocument Open "c:\test\a.html" For Input As #1 body = Input(4188, #1) hd.body.innerHTML = body Debug.Print hd.body.outerText I try do it with VC++ so: IHTMLDocument2 *pHtmlDoc = NULL; HRESULT hr; hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (LPVOID *) &pHtmlDoc); IHTMLElement *pBody; hr = pHtmlDoc->createElement(CComBSTR("BODY"), &pBody); CComBSTR bsText; hr = pBody->get_outerHTML(&bsText); // OK, we have "" CComBSTR SomeText("Some Text); hr = pBody->put_outerHTML((BSTR)SomeText); // ;-( falls It falls down while "put_outerHTML" Who know right solution? PS Set hd = New HTMLDocument creates an object with html code with base document structure (5 tags: html, body, head, title, p). CoCreateInstance creates absolutely empty object. Why? ================================ My products are here
-
I want to convert HTML to TEXT from some string It good works in VB code like this: Dim body As String Dim hd As HTMLDocument Dim str As String Set hd = New HTMLDocument Open "c:\test\a.html" For Input As #1 body = Input(4188, #1) hd.body.innerHTML = body Debug.Print hd.body.outerText I try do it with VC++ so: IHTMLDocument2 *pHtmlDoc = NULL; HRESULT hr; hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (LPVOID *) &pHtmlDoc); IHTMLElement *pBody; hr = pHtmlDoc->createElement(CComBSTR("BODY"), &pBody); CComBSTR bsText; hr = pBody->get_outerHTML(&bsText); // OK, we have "" CComBSTR SomeText("Some Text); hr = pBody->put_outerHTML((BSTR)SomeText); // ;-( falls It falls down while "put_outerHTML" Who know right solution? PS Set hd = New HTMLDocument creates an object with html code with base document structure (5 tags: html, body, head, title, p). CoCreateInstance creates absolutely empty object. Why? ================================ My products are here