 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
dpap Guest
|
Posted: Sun Dec 12, 2004 11:38 am Post subject: WinInet question |
|
|
Hi,
I use WinInet unit (D5ent) to ask the totalsize of a team of files with
this code :
var URLs : array of string;
buf : shortString;
totalSize := 0;
hSession :=
InternetOpen(PChar(extractFileName(application.exename)),INTERNET_OPEN_TYPE_
PRECONFIG,nil, nil, 0);
if hSession <> nil then begin
for iURL := 0 to length(URLs)-1 do begin
hURL := InternetOpenURL(hSession,PChar(URLs[iURL]),nil,0,0,0);
if hURL = nil then continue;
dw := bufferSize;
reserved := 0;
if
HttpQueryInfo(hURL,HTTP_QUERY_CONTENT_LENGTH,@buf[1],dw,reserved)
then begin
buf[0] := char(dw mod 256);
totalSize := totalSize + strToInt(buf);
end;
end;
internetCloseHandle(hSession);
end;
This code works ok for one or two repeats but stucks after this at "hURL :=
InternetOpenURL(....)". What I'm doing wrong ?
thanks in advance
|
|
| Back to top |
|
 |
danny heijl Guest
|
Posted: Sun Dec 12, 2004 12:05 pm Post subject: Re: WinInet question |
|
|
dpap schreef:
| Quote: | This code works ok for one or two repeats
but stucks after this at "hURL :=
InternetOpenURL(....)". What I'm doing wrong ?
|
From the MS SDK:
"After the calling application has finished using the HINTERNET handle
returned by InternetOpenUrl, it must be closed using the
InternetCloseHandle function."
Danny
---
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun Dec 12, 2004 1:11 pm Post subject: Re: WinInet question |
|
|
"dpap" <dpap (AT) softwaypro (DOT) gr> wrote
| Quote: | I use WinInet unit (D5ent) to ask the totalsize of a team of files with
this code : |
<snip>
Try this code instead:
function GetTotalSizes(URLs : array of string): DWORD;
var
hSession, hURL : HINTERNET;
iURL : Integer;
dw, size, reserved : DWORD;
begin
Result := 0;
hSession :=
InternetOpen(PChar(ExtractFileName(Application.ExeName)),
INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if hSession <> nil then begin
for iURL := 0 to Length(URLs)-1 do begin
hURL := InternetOpenURL(hSession, PChar(URLs[iURL]), nil, 0,
0, 0);
if hURL <> nil then begin
dw := SizeOf(DWORD);
reserved := 0;
if HttpQueryInfo(hURL, HTTP_QUERY_CONTENT_LENGTH or
HTTP_QUERY_FLAG_NUMBER, @size, dw, reserved) then begin
Inc(Result, size);
end;
InternetCloseHandle(hURL);
end;
end;
InternetCloseHandle(hSession);
end;
end;
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|