我試圖用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