function TForm1.GetProgramDir:string; var s:string; begin s:=Paramstr(0); while pos('\',s2)<>0 do begin result:=result+copy(s2,1,pos('\',s2)); delete(s2,1,pos('\',s2)); end; end;