在Firemonkey中获取应用程序路径

时间:2013-03-05 08:24:57

标签: delphi delphi-xe3 firemonkey-fm2

所以在VCL中,可以使用以下代码行来检索应用程序路径:

ExtractFilePath(Application.ExeName)

我尝试了同样的事情Firemokey,我注意到ExeName不再可用。我可以使用哪些代码作为替代方案?

3 个答案:

答案 0 :(得分:22)

尝试使用ParamStr(0)而不是Application.ExeName。

答案 1 :(得分:2)

我正在使用

showmessage(System.SysUtils.GetCurrentDir);

并且像魅力一样:)

答案 2 :(得分:1)

我在http://arcana.sivv.com/blog/找到了你可以试试这个:

X.Env.ExeFilename - 返回正在运行的可执行文件的实际文件名。

来自该博客的一些解释:

X.Env.SearchPath - Returns the currently registered search path on the system.
X.Env.AppFilename - Returns the "app" name of the application.  On OS X this is the application package in which the exe resides.  On Windows, this is the name of the folder in which the exe resides.
X.Env.ExeFilename - Returns the actual filename of the running executable.
X.Env.AppFolder - Returns the folder path to the executable, stopping at the level of the application package on OSX.
X.Env.ExeFolder - Returns the full folder path to the executable.
X.Env.TempFolder - Returns a writable temp folder path that can be used by your application.
X.Env.HomeFolder - Returns the user's writable home folder.  On OS X this equates to /Users/username and on Windows,  C:\Users\username\AppData\Roaming or the appropriate path as set on the system.