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

Вниз

Есть ли в Delphi функция , которая возвращает из URL файл ?   Найти похожие ветки 

 
GreySerg   (2003-10-09 19:53) [0]

Есть ли в Delphi функция , которая возвращает из URL файл ?
То есть, если у нас URL= http://mysite.narod.ru/update.udt , то эта функция должна вернуть update.udt


 
Юрий Федоров ©   (2003-10-09 19:56) [1]

А ExtractFileName не вернет случайно ?
В крайнем случае заменить / на \ ???


 
Brahman ©   (2003-10-09 20:03) [2]

Сам файл хочется ?
Поищи:
InternetReadFile(..)


 
GreySerg   (2003-10-09 20:18) [3]

>Юрий Федоров ©
ExtractFileName возвращает //mysite.narod.ru/update.udt
> Brahman
чё то InternetReadFile не находится


 
GreySerg   (2003-10-09 20:32) [4]

спасибо всем , сделал


 
Ломброзо Цезарь ©   (2003-10-09 20:47) [5]

InternetCrackUrl.
Вот позавчера на скорую руку наваял, сыро, но могу подарить ).
Нуждается в наличии интерпретатора VBScript, который на твоей машине наверняка уже стоит.
Классик разбирает URL на составляющие + параметры, переданные методом GET.

uses ... ComObj, ActiveX;

CGI = class
private
FList: TStringList;
FScheme: string;
FHostName: string;
FUrlPath: string;
function GetParam(const Key: string): string;
procedure SetParam(const Key, Value: string);
function GetScheme: string;
public
constructor Create(const URL: string);
destructor Destroy; override;
property Scheme: string read FScheme;
property HostName: string read FHostName;
property UrlPath: string read FUrlPath;
property Param[const Key: string]: string read GetParam write SetParam; default;
end;

constructor CGI.Create(const URL: string);
var pC: URL_COMPONENTS;
RE, Matches, match, Submatches: OleVariant;
Extra: string;
pURL: array [0..4096] of char;
ErrCode: DWORD;
i : integer;
Key, Value: string;
begin
inherited Create;
FList := TStringList.Create;
FillChar(pC, sizeof(URL_COMPONENTS), #0);
pC.dwStructSize := sizeof(URL_COMPONENTS);
StrCopy(pUrl, PChar(URL));
pC.dwSchemeLength := 100;
pC.dwHostNameLength := 100;
pC.dwUserNameLength := 100;
pC.dwPasswordLength := 100;
pC.dwUrlPathLength := 1000;
pC.dwExtraInfoLength := 1000;
if not InternetCrackUrl(@pURL[0], 0, 0, pC) then
begin
//ErrCode := GetLastError;
raise Exception.Create("Некорректный URL")
end;
FScheme := Copy(pC.lpszScheme, 1, pC.dwSchemeLength);
FHostName := Copy(pC.lpszHostName, 1, pC.dwHostNameLength);
Extra := Copy(pC.lpszExtraInfo, 1, pC.dwExtraInfoLength);
FUrlPath := Copy(pC.lpszUrlPath, 1, pC.dwUrlPathLength);
RE := CreateOleObject("VBScript.RegExp");
try
RE.Global := true;
RE.IgnoreCase := true;
RE.Pattern := "([^=?&]+)=([^=?&]+)";
Matches := RE.Execute(Extra);
for i := 0 to Matches.Count - 1 do
begin
Match := matches.Item[i];
Key := Copy(Match, 1, Pos("=", match) - 1);
Value := Copy(Match, Pos("=", Match) + 1, 1024);
FList.Values[Key] := Value;
end;
finally
RE := unassigned;
end;
end;

destructor CGI.Destroy;
begin
FList.Free;
inherited Destroy;
end;

function CGI.GetParam(const Key: string): string;
begin
Result := FList.Values[Key];
end;

function CGI.GetScheme: string;
begin
result := FScheme;
end;

procedure CGI.SetParam(const Key, Value: string);
begin
FList.Values[Key] := Value;
end;



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

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

Наверх




Память: 0.48 MB
Время: 0.015 c
1-74121
BillyJeans
2003-10-11 12:22
2003.10.23
Фоновый рисунок для ListBox и ListView


3-74092
Timur_2002
2003-10-02 02:17
2003.10.23
Текстовый курсор в DBGrid


3-74077
Юлия
2003-10-04 20:22
2003.10.23
Проблема с Locate с поиском поля типа date


1-74216
P0tia
2003-10-09 19:58
2003.10.23
Декомпиляция


7-74494
RomCom
2003-08-09 09:50
2003.10.23
Установка Tx COM-порта