I am using an instance of the IHTMLDocument2 interface to parse some HTML as described in this post:
Load from IPersistMoniker takes long time to load unresolvable URL
The code is relatively simple:
DelphiInterface<IHTMLDocument2> diDoc2;
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (LPVOID*)&diDoc2);
// Load and process HTML here and save into memory stream or to disk after the processing is done
When I am done I save the HTML contents of the newly modified diDoc2 above and load the HTML into TWebBrowser.
Can I instead just "assign" the already parsed
IHTMLDocument2above directly to theIHTMLDocument2contained in theTWebBrowser, which seems would be much faster way of doing it. I can use probablyIHTMLDocument2.writeor some other method to do so, but there would be likely some performance penalty than simply assigning a pointer to already initialized object, if that is possible in the first place. In other words, I simply want to "show"/"render" what I have just parsed in the "back buffer" of sort.Is there a need to call
CoInitializeandCoUninitializebefore and after callingCoCreateInstance? I've seen some code which does that but it works without it, unless Delphi/C++ Builder do some under-the-hood initialization.
I used
IHTMLDocument2.writeand it appears to work well.