Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2006.07.02;
Скачать: [xml.tar.bz2];

Вниз

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

 
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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.013 c
2-1150273031
Canchos
2006-06-14 12:17
2006.07.02
Упорядочивание массивов


15-1149710908
dimodim
2006-06-08 00:08
2006.07.02
APXS


1-1148220536
Userrrr
2006-05-21 18:08
2006.07.02
Скачать файл...???


15-1149648990
pargo
2006-06-07 06:56
2006.07.02
Доигрался с AppInit_DLLs :((


2-1150201602
JTAG
2006-06-13 16:26
2006.07.02
Господа подскажите плз, а самому иконку реально сделать





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский