| 发表于:2007-04-28 11:28:002楼 得分:100 |
msdn有完整例子 ms-help://ms.msdnqtr.v80.chs/ms.msdn.v80/ms.win32com.v10.en/xmlsdk/html/63409298-0516-437d-b5af-68368157eae3.htm #import "msxml3.dll " using namespace msxml2; void xmlhttprequestsample() { ixmlhttprequestptr pixmlhttprequest = null; bstr bstrstring = null; hresult hr; try { hr=pixmlhttprequest.createinstance( "msxml2.xmlhttp.3.0 "); succeeded(hr) ? 0 : throw hr; hr=pixmlhttprequest-> open( "get ", "http://localhost/books.xml ", false); succeeded(hr) ? 0 : throw hr; hr=pixmlhttprequest-> send(); succeeded(hr) ? 0 : throw hr; bstrstring=pixmlhttprequest-> responsetext; messagebox(null, _bstr_t(bstrstring), _t( "results "), mb_ok); if(bstrstring) { ::sysfreestring(bstrstring); bstrstring = null; } } catch (...) { messagebox(null, _t( "exception occurred "), _t( "error "), mb_ok); if(bstrstring) ::sysfreestring(bstrstring); } } | | |
|