FormMain.Caption:=getcurpath(application.Handle);
//获得当前应用程序所在路径
function getcurpath(hwnd_application:integer): string;
begin
  setlength(result,128);
  GetModuleFileName(hwnd_application, pchar(result), 128)
end;

解决方案 »

  1.   

    第一个参数为0:
    GetModuleFileName(0, pchar(result), 128)
      

  2.   

    var path :string;
    begin
      path:=ExtractFilePath(Application.ExeName);
      

  3.   

    extractfilepath(application.exename);
      

  4.   

    >> 已知其他窗口的句柄,如何得到其他窗口所在的文件名呢?GetModuleFileName(GetWindowLong(hwnd, GWL_HINSTANCE), PChar(s), Length(s));
      

  5.   

    var currentdir
    beging
    getdir(0,currentdir);
    showmessage(currentdir);
    end;
      

  6.   

    谢谢 sysu ,下次回答我的问题时我多给分你! 谢谢!!
      

  7.   

    extractfilepath(application.exename);