Hola,
La siguiente función está hecha un tanto a bote pronto siguiendo los artículos (no todos, ni tampoco completamente) que sobre el API WinInet hay publicados en "
La Web de JM". No recomiendo utilizar dicha función (aunque funciona, aparentemente) sino es antes leyendo y comprendiendo los artículos mencionados. Es claro que la función es muy mejorable, ya lo he dicho, pero, dejo al interesado que la mejore en cuanto pueda hacerse.
Código Delphi
[-]
uses
WinInet;
function TamanoArchivoInternet(URL: string) : Longint;
var
auxiliar: DWORD;
longitud: DWORD;
HUrl: HINTERNET;
HOpen: HINTERNET;
totalBytes: DWORD;
begin
totalBytes := 0;
HOpen := InternetOpen('Delphi Agent', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if (HOpen <> nil) then
begin
HUrl := InternetOpenUrl(HOpen, PChar(URL), nil, 0, INTERNET_FLAG_RELOAD, 0);
if (HUrl <> nil) then
begin
auxiliar := 0;
longitud := SizeOf(DWORD);
if (not HttpQueryInfo(HUrl, HTTP_QUERY_CONTENT_LENGTH or
HTTP_QUERY_FLAG_NUMBER, @totalBytes, longitud, auxiliar)) then
RaiseLastOSError;
end
else
RaiseLastOSError;
end
else
RaiseLastOSError;
if (HUrl <> nil) then
InternetCloseHandle(HUrl);
if (HOpen <> nil) then
InternetCloseHandle(HOpen);
Result := totalBytes;
end;
* Agradezco a
JM sus interesantísimos y completísimos artículos y tutoriales que tiene publicados en su página Web.