function getpath(str:string):string;
var i:integer;
begin
for i:=length(str) downto 1 do
if str[i]='\' then break;
if i>2 then result:=copy(str,0,i)
else Result:='';
end;
var i:integer;
begin
for i:=length(str) downto 1 do
if str[i]='\' then break;
if i>2 then result:=copy(str,0,i)
else Result:='';
end;
例子:
ExtractFilePath(Application.ExeName);
得到当前程序的运行路径,还有类似的函数,可以看看帮助