Forum > macOS / Mac OS X
Path to application
jwdietrich:
Is there a way to obtain the path to the running application in Mac OS X? ApplicationName returns simply the name of the application, not its directory.
jwdietrich:
I found the solution myself. The path can be obtained with ParamStr(0).
According to http://www.freepascal.org/docs-html/rtl/sysutils/applicationname.html ApplicationName and ParamStr(0) should deliver the same result by default, but obviously this is not the case.
In
--- Code: --- gAppName := ApplicationName;
gAppPath := ParamStr(0);
--- End code ---
gAppName contains the name of the application only, gAppPath the whole path.
marcov:
It is not guaranteed, since many OSes don't allow it.
(and some OSes e.g. only allow it when the file is on a native filesystem)
Zaher:
Check application.location
jwdietrich:
Great, it works!
Unfortunately, the Free Pascal documentation (see http://www.freepascal.org/docs-html/fcl/custapp/tcustomapplication.location.html) says that on Mac OS X application.location would not work "under certain circumstances". Im am afraid that I have to live with this uncertainty and check for a plausible value.
Navigation
[0] Message Index
[#] Next page