有STRING一变量 假设内容为C:\Documents and Settings\Administrator\桌面\612w.rar然后倒着找 \ 符号 找到后将 \后面的提取出来即可比如以上内容可获得612w.rar求函数 谢谢

解决方案 »

  1.   

    function GetAppDir(SAppPath:String): String;
    var
      tempstr:string;
    begin
    tempstr:='';
    while (Copy(SappPath,Length(SappPath),1)<>'\') and (Length(SappPath)>0) do
        begin
        tempstr:=Copy(SappPath,Length(SappPath),1)+tempstr;
        Delete(SappPath,length(SappPath),1);    
        end;    Result:=tempstr
    end;不知道对不对
      

  2.   

    ShowMessage(ExtractFileName(Application.ExeName));
      

  3.   

    SysUtils单元里有许多这样的函数,可以利用。
    例如,要实现你要的结果,可以用ExtractFileName函数。你可以Ctrl+单击看一下它的原型。下面是一个测试:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Showmessage(SysUtils.ExtractFileName('c:\abc\eee\sfs\8.exe'));//返回'8.exe'
    end;
    当然,如果先把字符串倒过来,再用pos查找\,然后再截取,再倒回来,也行,你可以参考你前几天问的一个贴子,有人回答过。
      

  4.   

    看这样写如何.
    var
      strlist: TStringList;
    begin
      strlist := TStringList.Create;
      try
        strlist.Delimiter := '\';
        strlist.DelimitedText := 'C:\Documents   and   Settings\Administrator\桌面\612w.rar';
        showmessage(strlist[strlist.Count-1]);
      finaly
        strlist.free;
      end;
    end;
      

  5.   

    捐了1000,好象会被CSDN扣掉10%的“税”....你将实得900可用分。