procedure Get(url: string;res: TStream);
var
hInt,hUrl:HINTERNET;
buffer,hBuf:PChar;
dwRead:cardinal;
flag:Boolean;
Len,index:Cardinal;
stream:TStringStream;
var value: DWORD;
begin
GetMem(buffer, 65536);
GetMem(hBuf, 65536);
hInt := InternetOpen('Delphi',INTERNET_OPEN_TYPE_PRECONFIG,nil,nil,0);
dwRead:=0;
hurl:=InternetOpenUrl(hInt,PChar(url),nil,0,INTERNET_FLAG_RELOAD,0);
//查询响应头信息
flag:=HttpQueryInfo(hurl,HTTP_QUERY_RAW_HEADERS_CRLF,hBuf,len,index);
stream:=TStringStream.Create('');
stream.Write(hBuf^,len);
ShowMessage(stream.DataString);
repeat
InternetReadFile(hUrl,buffer,1000,dwRead);
if dwRead<>0 then
res.Write(buffer^, dwRead);
until dwRead=0;
InternetCloseHandle(hUrl);
InternetCloseHandle(hInt);
FreeMem(buffer);
end;
rt
delphi HttpQueryInfo查询响应头信息,执行成功,返回true,len也不为0,但是我从缓冲区读出来的字符串却是空的,不知道是我读取缓冲区的方式不对还是怎么的,有谁搞过,请多多指教!