无忌兄,firstrose,可否帮忙一下,
我也用wininet写过,不过好像不行,
请问可否发个源码给我。感激不尽。
我写的wininet如下:
function GetWebPage(const Url: string):Ansistring;
const BufferSize = 1024;
var
hHttpSession, hReqUrl: HInternet;
Buffer: PChar;
NumRead, Index : DWord ;
Next : Boolean;
Content : Ansistring;
begin
NumRead := 0;
hHttpSession := InternetOpen ('MyHttp',INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
if hHttpSession <> nil then begin
hReqUrl := InternetOpenURL (hHttpSession, PChar(Url), nil, 0,0,0);
try
if hReqUrl <> nil then begin
Next := True ;
Content :='' ;
GetMem(Buffer,BufferSize);
Try
While Next do
begin
ZeroMemory(Buffer,BufferSize);
InternetReadFile (hReqUrl, Buffer, Sizeof(Buffer), NumRead);
if NumRead > 0 then
Content := Content + StrPas(Buffer)
else
Next := False;
end;
finally
FreeMem(Buffer,BufferSize);
end;
end;
finally
InternetCloseHandle(hReqUrl);
end;
end else begin
// Do Nothing
end;
finally
InternetCloseHandle (hHttpSession);
end;
Result:=Content;
end;