What's my path?
_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
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
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.
Also, GetModuleFileName(0) is a Windows call. The original poster didn''t specify an operating system.
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
"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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement