X
xuhao1
Unregistered / Unconfirmed
GUEST, unregistred user!
下载一个网页,有的电脑上1秒左右,有的确要10多秒,跟网速无关。
不知道是怎么回事。代码:
function GetURL(const aUrl: string): string;
const BufSize=1024;
var
hSession: HINTERNET;
hService: HINTERNET;
lpBuffer: string;
dwBytesRead: DWORD;
begin
Result:='';
SetLength(lpBuffer, BufSize);
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
if Assigned(hSession) then
begin
hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0);
if Assigned(hService) then
Repeat
InternetReadFile(hService, @lpBuffer[1], BufSize, dwBytesRead);
Result:=Result+Copy(lpBuffer, 0, dwBytesRead);
application.ProcessMessages;
until dwBytesRead = 0;
end;
finally
InternetCloseHandle(hService);
InternetCloseHandle(hSession);
end;
end;
不知道是怎么回事。代码:
function GetURL(const aUrl: string): string;
const BufSize=1024;
var
hSession: HINTERNET;
hService: HINTERNET;
lpBuffer: string;
dwBytesRead: DWORD;
begin
Result:='';
SetLength(lpBuffer, BufSize);
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
if Assigned(hSession) then
begin
hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0);
if Assigned(hService) then
Repeat
InternetReadFile(hService, @lpBuffer[1], BufSize, dwBytesRead);
Result:=Result+Copy(lpBuffer, 0, dwBytesRead);
application.ProcessMessages;
until dwBytesRead = 0;
end;
finally
InternetCloseHandle(hService);
InternetCloseHandle(hSession);
end;
end;