Getting application path in Firemonkey

2019-03-18 15:53发布

问题:

So in VCL, one would use the following line of code to retrieve the applications path:

ExtractFilePath(Application.ExeName)

I tried the same thing Firemokey and I noticed that ExeName was no longer available. What code can I use as an alternative to this?

回答1:

Try using ParamStr(0) instead of Application.ExeName.



回答2:

I'm using

showmessage(System.SysUtils.GetCurrentDir);

and works like a charm :)



回答3:

I found on http://arcana.sivv.com/blog/, you may try use this :

X.Env.ExeFilename - Returns the actual filename of the running executable.

Here some explanation from that blog :

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.