BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WinInet question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
dpap
Guest





PostPosted: Sun Dec 12, 2004 11:38 am    Post subject: WinInet question Reply with quote



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





PostPosted: Sun Dec 12, 2004 12:05 pm    Post subject: Re: WinInet question Reply with quote



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





PostPosted: Sun Dec 12, 2004 1:11 pm    Post subject: Re: WinInet question Reply with quote




"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.