Форум: "Начинающим";
Текущий архив: 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