B
Bura Tino
Hi,
I took a sample below almost verbatim from the MS MSXML 3.0 website and the
line
hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP");
never succeeds. What am I doing wrong?
It says on the webpage that I need as msxml2.lib on my machine, but I can't
seem to find it. I'm running WindowsXP SP1. Could that be it.
Finally, my compiler does not recognize the _T() function or marco so I
commented it out.
(I'm completely new to VC++ programming.)
Thanks.
Bura.
// XMLRequest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#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://localhost/index.html",
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);
fprintf(stderr, "Exception!!!!");
if(bstrString)
::SysFreeString(bstrString);
}
}
int main(int argc, char* argv[]) {
XMLHttpRequestSample();
return 0;
}
I took a sample below almost verbatim from the MS MSXML 3.0 website and the
line
hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP");
never succeeds. What am I doing wrong?
It says on the webpage that I need as msxml2.lib on my machine, but I can't
seem to find it. I'm running WindowsXP SP1. Could that be it.
Finally, my compiler does not recognize the _T() function or marco so I
commented it out.
(I'm completely new to VC++ programming.)
Thanks.
Bura.
// XMLRequest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#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://localhost/index.html",
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);
fprintf(stderr, "Exception!!!!");
if(bstrString)
::SysFreeString(bstrString);
}
}
int main(int argc, char* argv[]) {
XMLHttpRequestSample();
return 0;
}