#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;
}
CoUninitialize 退出时 m_pInterface->Release()崩溃 解决
最新推荐文章于 2022-01-12 10:34:27 发布