procedure TForm1.FormCreate(Sender: TObject);
begin
LogTimes := 0;
ChDir(ExtractFilePath(Application.ExeName));
ChDir('..');
ExeRootPath := GetCurrentDir;
{ used language }
ParaIni := TInifile.Create(ExeRootPath+'/config/parameter.ini');
Lang := ParaIni.ReadString('sys','lang','cn');
end;
begin
LogTimes := 0;
ChDir(ExtractFilePath(Application.ExeName));
ChDir('..');
ExeRootPath := GetCurrentDir;
{ used language }
ParaIni := TInifile.Create(ExeRootPath+'/config/parameter.ini');
Lang := ParaIni.ReadString('sys','lang','cn');
end;
ChDir(ExtractFilePath(Application.ExeName)); //切换到当前程序目录,其实这句可以不要的,默认的目录就是了
ChDir('..'); //当前程序的上级目录
ExeRootPath := GetCurrentDir; //获取当前目录,结果为当前程序的上级目录
ExtractFilePath(FileName:String) 该函数返回路径名,其结尾字符总是“\”
ExtractFileDir(FileName:String) 该函数同样返回路径名,但不包括结尾的字符“\”,除非返回的路径是根目录。
如:
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(ExtractFileDir(Application.Exename)); // 如: c:\temp
ShowMessage(ExtractFilePath(Application.Exename)); // 如: c:\temp\
end;
str:=GetCurrentDir();
如果要得到系统的当前目录使用Path := GetCurrentDir;
如果要得到程序的当前目录使用Path := ExtractFilePath( Application.ExeName ); str:=GetCurrentDir();
如果要得到系统的当前目录使用Path := GetCurrentDir;
如果要得到程序的当前目录使用Path := ExtractFilePath( Application.ExeName );
http://hi.baidu.com/langyanqi/blog/item/26bec1ceaf21850093457e46.html