Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.024 c
2-1149864309
VitV
2006-06-09 18:45
2006.07.02
"Привязка" клавиши к кнопке.


1-1148291731
DmitryFox
2006-05-22 13:55
2006.07.02
Окна StayOnTop только поверх окон приложения


3-1146809487
marcel
2006-05-05 10:11
2006.07.02
Создание исключения при добавлении данных в БД


2-1150117603
Сашок
2006-06-12 17:06
2006.07.02
Help


1-1148474037
Layner
2006-05-24 16:33
2006.07.02
public mymass: array of integer - не виден в другом модуле :(




   Наверх