-2

I am developing a visual c++ application for creating preview handler. The problem occurs when i for some reason i need to do CoCreateInstance() for IXMLDOMDocument *pDomDoc; inside the static function (pay attention here). and the syntax is as follows-

//this CreateHtmlPreview is declared static somewhere in my code
HRESULT AMEPreviewHandler:: CreateHtmlPreview(AMEPreviewHandler* instance)
{
    IStream *m_FinalHTMLStream;
    ULONG pcbWritten;
    HRESULT hrs = CreateStreamOnHGlobal(NULL, TRUE, &m_FinalHTMLStream);
    HRESULT hrp = m_FinalHTMLStream->Write(&(instance->m_HtmlFileContents),(instance->m_SizeOfFile)-1, &pcbWritten);
IXMLDOMDocument *pDomDoc;
HRESULT hr = CoCreateInstance(__uuidof(DOMDocument60), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDomDoc));
//the problem is here that this hr on debugging gives EFAIL

         if (SUCCEEDED(hr))
            {
     ................Something..something.......
}
}

Is that due to static declaration of the function.If NO ?? Then what could be the reason for this EFAIL ???

4

1 回答 1

2

调用CoCreateInstance不知道它是否来自static函数。您从函数调用的事实static不是问题。CoCreateInstance从任何类型的函数调用都很好。

于 2013-07-31T09:50:29.110 回答