Archived

This topic is now archived and is closed to further replies.

ToxicSoul

What's my path?

Recommended Posts

Endurion    5408
_getcwd (get current working directory) will NOT always be the path where your app resides in.

Imagine starting an exe from dos-box like this:

c:\program files\>d:\yourapp.exe

argv[0] or GetModuleFileName(0) is your way to go, but you have to strip the filename of your app from the string.

Regards,
Endurion

Share this post


Link to post
Share on other sites
Poontardis    122
Ah, but it''s possible that argv[0] is empty (I had this last week when trying to insert a custom executable into a make process.) I''m not certain of exactly when it''s empty (I couldn''t really be bothered checking) but I think calling an exe through a batch process might result in an empty argv[0].

Also, GetModuleFileName(0) is a Windows call. The original poster didn''t specify an operating system.

Share this post


Link to post
Share on other sites
Arild Fines    968
IIRC, argv[0] isn''t required to include the full path to the executable.



"I know very well who Satan is: He is freedom. He is the uncontrolled, the incalculable, the antithesis of order and discipline, the antithesis of the legalism of outer space.... We know where a planet will be in twelve years, four months and nine days. But we don''t know where a butterfly will have flown one minute hence. Therefore the butterfly is of Satan."
-- Jens Bjørneboe

Share this post


Link to post
Share on other sites