Forum > macOS / Mac OS X

Path to application

(1/4) > >>

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.

I found the solution myself. The path can be obtained with ParamStr(0).

According to ApplicationName and ParamStr(0) should deliver the same result by default, but obviously this is not the case.


--- Code: ---  gAppName := ApplicationName;
  gAppPath := ParamStr(0);
--- End code ---

gAppName contains the name of the application only, gAppPath the whole path.

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)

Check application.location

Great, it works!

Unfortunately, the Free Pascal documentation (see 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.


[0] Message Index

[#] Next page

Go to full version