Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)aaapublished in(发表于) 2014/7/19 0:13:17 delphi获取当前目录
获取当前目录要获取当前目录的位置,即应用程序的执行目录,可以调用Win32 的GetCurrentDirectory()函数。该函数的用法与GetSystemDirectory()、GetWindowsDirectory()相似,所不同的是,参数的顺序刚好相反。下面的示例代码演示了GetCurrentDirectory()的用法。procedure TForm1.Button1Click(Sender: TObject);varCurrDir:String;beginSetLength(CurrDir,144);if GetCurrentDirectory(144,(PChar(CurrDir)))<>0 thenbeginSetLength(CurrDir,Length(PChar(CurrDir)));Edit1.Text:=CurrDir;endelseRaiseLastWin32Error;end;
赞