procedure Get(url,heads: string;res: TStream);
var
hInt,hUrl:HINTERNET;
buffer:PChar;
dwRead:cardinal;
hBuf:PChar;
flag:Boolean;
len,index:Integer;
var value: DWORD;
begin
GetMem(buffer, 65536);
GetMem(hBuf, 65536);
hInt := InternetOpen('Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',INTERNET_OPEN_TYPE_PRECONFIG,nil,nil,0);
dwRead:=0;
if Trim(heads)<>'' then
hurl:=InternetOpenUrl(hInt,PChar(url),PAnsiChar(AnsiString(heads)),Length(AnsiString(heads)),INTERNET_FLAG_RELOAD,0)
else
hurl:=InternetOpenUrl(hInt,PChar(url),nil,0,INTERNET_FLAG_RELOAD,0);
//获取响应头信息
flag:=HttpQueryInfo(hurl,HTTP_QUERY_RAW_HEADERS_CRLF,hBuf,len,index);
//showmessage(StrPas(hBuf));
repeat
InternetReadFile(hUrl,buffer,1000,dwRead);
if dwRead<>0 then
res.Write(buffer^, dwRead);
until dwRead=0;
InternetCloseHandle(hUrl);
InternetCloseHandle(hInt);
FreeMem(buffer);
end;
报错是从len参数开始报错的,我看了函数,最后两个参数是var的,我试着传过地址也不行,我看网上有人跟我一样的就行就我的不行,有谁搞过,请多多指教!