我正在尝试使用MS XMLHTTP COM获取HTTP文档的内容。虽然我已经复制了以下示例代码,但即使如此,它也无法正常工作,并在send方法调用时失败并出现“EOLEException错误”'Access is denied'。
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