娱乐新地带论坛

娱乐新地带论坛 (https://bbs.1819.net/index.php)
-   『程序设计』 (https://bbs.1819.net/forumdisplay.php?f=20)
-   -   一个解析ftp地址的小函数 (https://bbs.1819.net/showthread.php?t=58353)

Erika 2007-12-20 01:51 PM

一个解析ftp地址的小函数
 
procedure TForm1.FTPAnalysis(S:string;var UserName,Password,IP,FileName:String;var DirList:TStringList);
var
i,j:integer;
strAuthorization,strAddr,strDirFile:string;//授权信息
begin
UserName:= ’anonymous’;
Password:= ’test@test.com’;
IP := ’’;
strAddr := Copy(S,7,length(S)-6);//取得ftp://之后的部分
//S 格式必须是类似ftp://rec:ooo@192.168.76.11/20050418...192.168.76.11/......
i := Pos(’@’,S);
if(i>0) then
begin
strAuthorization := Copy(S,7,i-7); //只取帐号密码字段
j:=Pos(’:’,strAuthorization);
if(j<1)then
exit;
UserName := Copy(strAuthorization,1,j-1);
PassWord := Copy(strAuthorization,j+1,length(strAuthorization)-j);
end;
i := Pos(’@’,strAddr);
j:=Pos(’/’,strAddr);
if(j>0) then
IP := Copy(strAddr,i+1,j-i-1);//获得IP地址
strDirFile := Copy(strAddr,j+1,length(strAddr)-j);
DirList.Delimiter := ’/’;
DirList.DelimitedText := strDirFile;//获得目录列表
FileName := DirList[DirList.count-1];//最后部分为文件名
DirList.Delete(DirList.Count-1);

end;


所有时间均为北京时间。现在的时间是 07:26 AM

©2003-2024 1819.net All rights reserved. © 2024