unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,wininet, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
aURLC: TURLComponents;
const
TEST_URL = '
ftp://user:pass@host:port/dir/file.exe';
begin
FillChar(aURLC, SizeOf(TURLComponents), 0);
with aURLC
do
begin
lpszScheme :=
nil;
dwSchemeLength := INTERNET_MAX_SCHEME_LENGTH;
lpszHostName :=
nil;
dwHostNameLength := INTERNET_MAX_HOST_NAME_LENGTH;
lpszUserName :=
nil;
dwUserNameLength := INTERNET_MAX_USER_NAME_LENGTH;
lpszPassword :=
nil;
dwPasswordLength := INTERNET_MAX_PASSWORD_LENGTH;
lpszUrlPath :=
nil;
dwUrlPathLength := INTERNET_MAX_PATH_LENGTH;
lpszExtraInfo :=
nil;
dwExtraInfoLength := INTERNET_MAX_PATH_LENGTH;
dwStructSize := SizeOf(aURLC);
end;
if InternetCrackUrl(PChar(TEST_URL), Length(TEST_URL), 0, aURLC)
then
begin
ShowMessage(aURLC.lpszUrlPath);
end;
end;
end.