• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 938
  • Last Modified:

problem facing with IHTMLDocument2::write function

I am facing two problems when the control of my project comes at IHTMLDocument2::write" function.The problems are as follows..

1. My project is going in hang stag .
2. It throws exception at the same point.

i have attached two html files , abc.html and xyz.html for respected problems.

The code what i am using is to write HTML expressions to a document is::

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

if(!strHtmlText.IsEmpty() && SUCCEEDED(hr))
      psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
      VARIANT *param;

      if(psa && SUCCEEDED(SafeArrayAccessData(psa, (LPVOID*)&param)))
            CComBSTR bstrHTML(strHtmlText);
            param->vt = VT_BSTR;
            param->bstrVal = bstrHTML.m_str;
            if(SUCCEEDED( pDoc->write(psa)))

  • 2
1 Solution
Pramod BugudaiCommented:

I can see that you have a COM DLL, from which you are trying to call the methods to create your HTML documents. Whether you tested your COM DLL to check its working fine. I guess something its not able to find out the process address of routines in that DLL. That is the reason its hanging your application.

Exceptions are may from your program. Try debugging the application where exactly it starts hanging your app.

davinder101Author Commented:

i have tested this piece of code on a dialog based application too.

just add this piece of code on a click event on a dialog based application
it hangs on even on that.

please check it at your end too...
it will hang...
Pramod BugudaiCommented:
I was trying to tell you for proper debugging so that exactly you can find where it starts hanging and then crashing the app.Not sure what is there in your code. But while googling I got these links, which will be helpful for you.


Put a search in google "CoCreateInstance(CLSID_HTMLDocument" you will get more links. That may help you more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now