Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.07.02;
Скачать: CL | DM;

Вниз

Как узнать размер файла в интернете, и что возвращает   Найти похожие ветки 

 
novill ©   (2006-06-14 16:31) [0]

функция InternetQueryDataAvailable?


 
isasa ©   (2006-06-14 16:43) [1]

А в MSDN?

Queries the server to determine the amount of data available.

BOOL InternetQueryDataAvailable(
 HINTERNET hFile,
 LPDWORD lpdwNumberOfBytesAvailable,
 DWORD dwFlags,
 DWORD_PTR dwContext
);

Parameters
hFile
[in] Handle returned by the InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest function.
lpdwNumberOfBytesAvailable
[out] Pointer to a variable that receives the number of available bytes. May be NULL.
dwFlags
[in] Reserved. Must be zero.
dwContext
[in] Reserved. Must be zero.
Return Values
Returns TRUE if the function succeeds, or FALSE otherwise. To get extended error information, call GetLastError. If the function finds no matching files, GetLastError returns ERROR_NO_MORE_FILES.
Remarks
This function returns the number of bytes of data that are available to be read immediately by a subsequent call to InternetReadFile. If there is currently no data available and the end of the file has not been reached, the request waits until data becomes available. The amount of data remaining will not be recalculated until all available data indicated by the call to InternetQueryDataAvailable is read.



 
novill ©   (2006-06-14 16:46) [2]

Я только что оттуда (из MSDN)
насокль я понял фраза
[out] Pointer to a variable that receives the number of available bytes. May be NULL.
означает что в переменной окажется размер файла. Если нет, то что туда попадает?


 
Zeqfreed ©   (2006-06-15 12:50) [3]


uses Sockets;

. . .

function GetDocSize(const Server, Doc, Port : String) : Integer;
const
 CRLF = #13#10;
var
 Response : String;
 Get : String;
begin
 Result := -1;

 with TTcpClient.Create(nil) do begin
  try
   RemoteHost := LookupHostAddr(Server);
   RemotePort := Port;
   Connect();
   if Connected then begin
    Get := "GET http://" + Server + ":" + Port + "/" + Doc + " HTTP/1.0" + CRLF +
           "Host: " + Server + CRLF +
           "Connection: close" + CRLF;
    Sendln(Get, CRLF);

    Response := Receiveln(CRLF + CRLF);
    if Pos("200 OK", Response) > 0 then
     with TStringList.Create do begin
      try
       Text := Response;
       NameValueSeparator := ":";
       TryStrToInt(Values["content-length"], Result);
      finally
       Free;
      end;
     end;
   end;
  finally
   Free;
  end;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 ShowMessage(Format("Doc size is: %2.2f Kbytes", [GetDocSize("delphimaster.ru", "404.html", "80") / 1024]));
end;


 
Сергей М. ©   (2006-06-15 13:15) [4]


> Если нет, то что туда попадает?


Куда попадать-то ?
Если ты указал NULL, значит тебя не интересуют эти данные.


 
evvcom ©   (2006-06-15 13:25) [5]

> [out] Pointer to a variable that receives the number of
> available bytes. May be NULL.
> означает что в переменной окажется размер файла. Если нет,
> то что туда попадает?

означает, что по адресу, на кот. указатель кажет, окажется число. Может быть null (или в Delphi nil, т.е. пустой указатель), если это число тебя не интересует.



Страницы: 1 вся ветка

Текущий архив: 2006.07.02;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.053 c
1-1148288513
TSa
2006-05-22 13:01
2006.07.02
Узнать путь к общей папке


2-1149847414
Balkon
2006-06-09 14:03
2006.07.02
Причина ошибки Access Violation


2-1149817570
Василий
2006-06-09 05:46
2006.07.02
Работа печати через "Begindoc...EndDoc"


2-1149828601
Layner
2006-06-09 08:50
2006.07.02
Как передать в создаваемую форму параметр, как в функцию


1-1148282805
Steplerr
2006-05-22 11:26
2006.07.02
Выдирание иконок из защищённых файлов