IXMLHTTPRequest.CreateInstance fails!

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;
}
 
B

Bura Tino

By the way, here's the exception when I press F5:

Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\oleaut32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\clbcatq.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\comres.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information
found.
First-chance exception in XMLRequest.exe (KERNEL32.DLL): 0xE06D7363:
Microsoft C++ Exception.
The thread 0xFC has exited with code 0 (0x0).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top