如,我编辑一个程序保存在d:\data\d.ini 下,现在我在程序中怎么写代码取本地的d.ini文件啊??
我这样写的CopyFile('\CaaNew.mdb',pchar(filename),true);这样不行的,具体怎么写啊,拜托了!

解决方案 »

  1.   

    strTmp := getStanPath(ExtractFilePath(application.Exename));
      result := strTmp;
      

  2.   

    getcurrentdir()
    setcurrentdir()
    ExtractFilePath(paramstr(0))
      

  3.   

    最好不要用GetCurrentDir(),ExtractFilePath(Application.Exename)倒是可以,因为第一个用完了如果进行打开文件等操作后,得到的路径就会发生变化
      

  4.   

    GetCurrentDir()在用OpenDialog等操作后,路径就不是当前的路径了,所以最好的办法是用ExtractFilePath(Application.Exename),要不然会害死你。
      

  5.   

    ExtractFilePath(Application.Exename);
      

  6.   

    function GetApplicationDir: string;
    var
      hModule:THandle;
      buf:array [0..MAX_PATH] of char;
      hlpd:string;
    begin
      hModule:=GetModuleHandle(nil);
      GetModuleFileName(hmodule,buf,sizeof(buf));
      hlpd:=string(PChar(ExtractFileDir(buf)));
      if hlpd[Length(hlpd)]='\' then
        Result:=hlpd
      else
        Result:=hlpd+'\';
    end;
      

  7.   

    var
    sPath : string;
    begin
         sPath := ExtractFilePath(application.Exename);
         showmessage(sPath); //你会看到spath中存放的是你程序所在目录的路径
    end;