function GetWebPage(const Url: string):string;
var
Session,
HttpFile:HINTERNET;
szSizeBuffer: array [0..1023] of char;// szSizeBuffer
ointer;
dwLengthSizeBuffer
Word;
dwReserved
Word;
dwFileSize
Word;
dwBytesRead:DWord;
Contents
Char;
begin
Session:=InternetOpen('',0,niL,niL,0);
HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0);
if not Assigned(HttpFile) then
Exit;
FillChar(szSizeBuffer, SizeOf(szSizeBuffer), #0); // HttpQueryInfo 缓冲区
dwLengthSizeBuffer := SizeOf(szSizeBuffer); //dwLengthSizeBuffer:=1024;
dwReserved := 0;
if not HttpQueryInfo(HttpFile,HTTP_QUERY_CONTENT_LENGTH,@szSizeBuffer[0],
dwLengthSizeBuffer,dwReserved) then
Exit;
dwFileSize := StrToInt(szSizeBuffer); // 文件大小
GetMem(Contents,dwFileSize);
InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead);
InternetCloseHandle(HttpFile);
InternetCloseHandle(Session);
Result:=StrPas(Contents);
FreeMem(Contents);
end;