Forum > macOS / Mac OS X
How can I get application directory?
dusanx:
--- Quote from: jmaebe on February 20, 2009, 12:10:17 am ---
--- Quote from: dusanx on February 18, 2009, 12:39:10 am ---ExtractFilePath(ParamStr(0));
Edit: and ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)))+'/../../somefolder' works too.
--- End quote ---
Paramstr(0) must only be used on Dos and Windows (and maybe OS/2). On all other platforms the results are unpredictable and it will not work as you expect (in the best case it will never work; in the worst case it will only fail under certain circumstances, resulting in hard-to-find bugs). Read the mailing list thread I quoted above for more information.
--- End quote ---
Sorry because of late answer: It's weird, I just finished Win/Mac/Linux project that uses ParamStr(0) and I get proper path everywhere? :-\
Leledumbo:
--- Quote ---Sorry because of late answer: It's weird, I just finished Win/Mac/Linux project that uses ParamStr(0) and I get proper path everywhere?
--- End quote ---
Try it on symlinks.
dusanx:
Makes sense, I did not used them and it worked.
Jonas Maebe:
--- Quote from: dusanx on February 25, 2009, 09:14:50 am ---
--- Quote from: jmaebe on February 20, 2009, 12:10:17 am ---
--- Quote from: dusanx on February 18, 2009, 12:39:10 am ---ExtractFilePath(ParamStr(0));
Edit: and ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)))+'/../../somefolder' works too.
--- End quote ---
Paramstr(0) must only be used on Dos and Windows (and maybe OS/2). On all other platforms the results are unpredictable and it will not work as you expect (in the best case it will never work; in the worst case it will only fail under certain circumstances, resulting in hard-to-find bugs). Read the mailing list thread I quoted above for more information.
--- End quote ---
Sorry because of late answer: It's weird, I just finished Win/Mac/Linux project that uses ParamStr(0) and I get proper path everywhere? :-\
--- End quote ---
As I said: "in the worst case it will only fail under certain circumstances". Once more: please read the threads I mentioned earlier for the details. It contains several examples of cases where it will fail.
Bogen85:
A new thread for this subject is here: https://forum.lazarus.freepascal.org/index.php/topic,61919.0.html
(Don't continue this thread, use the new thread)
Navigation
[0] Message Index
[*] Previous page