Главная страница
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.029 c
2-1149862619
Ladan
2006-06-09 18:16
2006.07.02
MediaPlayer and TrackBar


2-1149847180
VitV
2006-06-09 13:59
2006.07.02
Хранения данных в из DBRichedit.


3-1146644994
Juice
2006-05-03 12:29
2006.07.02
LangId_To_CodePage - Ошибка Left side cannot be assigned to


2-1149941024
demonygas
2006-06-10 16:03
2006.07.02
Плиз! Помогите осуществить перевод вешественного числа в строку


2-1150265000
Maxim_82
2006-06-14 10:03
2006.07.02
Помогите установить компонеты DSPack