我试图用MS XMLHTTP COM检索HTTP文档的内容。我确实复制了下面的示例代码,但即使这样也不起作用,并且在发送方法调用时发生EOLEException错误“访问被拒绝”时失败并返回。XMLHTTP和“访问被拒绝”错误
uses
MSXML, ComObj, ActiveX;
procedure TForm1.Button1Click(Sender: TObject);
var
httpDoc: XMLHTTP; // IXMLHTTPRequest
begin
httpDoc := CreateOleObject('MSXML2.XMLHTTP') as XMLHTTP;
try
httpDoc.open('GET', 'http://www.google.com/index.html', False, EmptyParam, EmptyParam);
httpDoc.send(''); // <-- EOLEException 'Access is denied'
if (httpDoc.readyState = 4) and (httpDoc.status = 200) then
ShowMessage(httpDoc.responseText);
finally
httpDoc := nil;
end;
end;
我真的不知道我在做什么错:(
同时检查'send'真的让空字符串参数而不是规范的'null' – OnTheFly 2011-12-30 07:55:01