首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

请大家看看代码写的有哪些异常

2012-03-17 
请大家看看代码写的有哪些错误。C/C++ codeint CWlyGView::ShowHtml(CString strHtml){CComPtrIHTMLDocume

请大家看看代码写的有哪些错误。

C/C++ code
int CWlyGView::ShowHtml(CString strHtml){    CComPtr<IHTMLDocument2> pDoc;    CComPtr<IHTMLElementCollection> sphtmlAll;    CComPtr<IHTMLScriptElement> spObject;    CComPtr<IDispatch> spDisp;    CComVariant varName;    CComVariant varIndex;    [color=#FF0000]if(FAILED((IHTMLDocument2*)this->GetHtmlDocument(),(&pDoc)) || pDoc==NULL)        return 0;[/color]    CComQIPtr<IPersistStreamInit> spPersistStream(pDoc);    if(spPersistStream==NULL)        return 0;    LPTSTR lpMem = (LPTSTR)::GlobalAlloc( GPTR,strHtml.GetLength()+1);    lstrcpy(lpMem,strHtml.GetBuffer());    CComPtr<IStream>spStream;    CreateStreamOnHGlobal( lpMem, TRUE, &spStream );    // 初始化后,装载显示    spPersistStream->InitNew();    spPersistStream->Load(spStream );    return 0;}


为什么程序执行到红色代码那里就停了。请大家看看代码写的有哪些错误。CWlyGView是我的主视图类。谢谢!

[解决办法]
if(FAILED((IHTMLDocument2*)this->GetHtmlDocument(),(&pDoc)) || pDoc==NULL)
条件为真了。

热点排行