Hi,

I can't get the simple snippet of C++ code at the bottom of
http://msdn.microsoft.com/library/en...asp?frame=true
to run on my XP VC++ system.

The command hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP");
never succeeds and an exception is thrown.

Any suggestions?

#import "msxml3.dll"
using namespace MSXML2;

void XMLHttpRequestSample()
{
IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;
BSTR bstrString = NULL;
HRESULT hr;

try {
hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP");
SUCCEEDED(hr) ? 0 : throw hr;

hr=pIXMLHTTPRequest->open("GET",
"http://XMLSampleServer/CatalogServer.asp", 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);
}

}