0
点赞
收藏
分享

微信扫一扫

CoUninitialize 退出时 m_pInterface->Release()崩溃 解决

_鱼与渔_ 2022-01-12 阅读 18

转载地址:CoUninitialize 退出时 m_pInterface->Release()崩溃 解决_Qyee16的博客-CSDN博客

调试在m_pInterface->Release时报错

void _Release() throw()
{
if (m_pInterface != NULL) {
m_pInterface->Release();
}
}

#include "stdafx.h"  
#import "msxml3.dll"  
using namespace MSXML2;  
  
void myExit()  
{  
    ::CoUninitialize();  
}  
  
int main(void)  
{  
    ::CoInitialize(NULL);  
    MSXML2::IXMLDOMDocumentPtr     pDoc;            
    MSXML2::IXMLDOMElementPtr         xmlRoot     ;        
    HRESULT     hr     =     pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));        
    if(!SUCCEEDED(hr))            
    {                                                            
        //MessageBox("无法创建DOMDocument对象,请检查是否安装了MS     XML     Parser     运行库!");            
    }            
  
    pDoc->raw_createElement((_bstr_t)(char*)"china",     &xmlRoot);        
    //MSXML2::IXMLDOMNodePtr     childnode     =     xmlnode;        
    pDoc->raw_appendChild(xmlRoot,     NULL);        
  
    MSXML2::IXMLDOMElementPtr         childNode     ;        
  
    pDoc->raw_createElement((_bstr_t)(char*)"City",     &childNode);        
    childNode->Puttext("WuHan");        
    childNode->setAttribute("population","8,000,000");        
    childNode->setAttribute("area","10000");        
    xmlRoot->appendChild(childNode);        
  
    pDoc->raw_createElement((_bstr_t)(char*)"City",     &childNode);        
    childNode->Puttext("ShangHai");        
    childNode->setAttribute("population","12,000,000");        
    childNode->setAttribute("area","12000");        
    xmlRoot->appendChild(childNode);        
  
    pDoc->save("f:\\he.xml");    
    pDoc=NULL;  
  
    //::CoUninitialize();  
    atexit(myExit);  
    return 0;  
}  
举报

相关推荐

0 条评论