代码如下:请高人帮忙...
function getapplicationpath(showresult:boolean):string  ;
result:=paramstr(0);
result:=extractfilepath(result);
 if showresult then
 showmessage('程序的路径是:'+result);
end;
procedure showresult(info:string);
begin
showmessage('程序的路径是:'+info);
procedure TForm1.Button1Click(Sender: TObject);
  var
  s:string;
begin
s:=getapplicationpath(false);
info(s);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
getapplicationpath(true);
end;end; 

解决方案 »

  1.   

    function GetApplicationPath(ShowResult: boolean): string;
    begin
      result:=ExtractFilePath(Application.FileName);
      if ShowResultthen
        showmessage('程序的路径是:'+result);
    end; 
      

  2.   

    function getapplicationpath(showresult:boolean):string;
    begin
      result:=paramstr(0);
      result:=extractfilepath(result);
      if showresult then
      showmessage('程序的路径是:'+result);
    end;procedure showresult(info:string);
    begin
      showmessage('程序的路径是:'+info);
    end;procedure TForm1.btn1Click(Sender: TObject);
    var
      s:string;
    begin
      s:=getapplicationpath(false);
      showresult(s);
    end;procedure TForm1.btn2Click(Sender: TObject);
    begin
      getapplicationpath(true);
    end;