Re: Application path



On Wed, 2011-01-12 at 13:13 +0000, John Emmas wrote:
 Is there any [...] function that would tell me the full path to the
application - e.g. "/usr/bin/my_app/my_app" under Linux, or "C:
\Program Files\my_app\my_app.exe" under Windows?

Not in general - it's best to decide you don't need this :-)

Some programs behave differently based on their name, but in C you can
use argv[0] to get at that, bearing in mind it might not actually
correspond to any filename at all.

If you do get the original file (whether via /proc or argv[0] or ps or
some other method), remember that on some systems it might have been
renamed, moved, or even deleted, after the program started, and also
that the user might have made a link, symbolic link, shortcut or
whatever...

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]