Does GetCurrentDirectory return the same path name of exe?
Hi,
I am making a simple app to get the full path name to the app and other files locate at the same directory. So I choose ::GetCurrentDirectory, but later I found what it retrieved is the directory where .vcproj resides, not the .exe. So I wonder if the app will correctly find where it is after distributed, and it adds much more difficulties to debug. Do you have any idea about it?
Thanks
[401 byte] By [
xkwooo] at [2007-11-20 9:39:34]

# 1 Re: Does GetCurrentDirectory return the same path name of exe?
Hi,
I am making a simple app to get the full path name to the app and other files locate at the same directory. So I choose ::GetCurrentDirectory, but later I found what it retrieved is the directory where .vcproj resides, not the .exe. So I wonder if the app will correctly find where it is after distributed, and it adds much more difficulties to debug. Do you have any idea about it?
Thanks
Because "executable file path" and "current directory" are not the same thing. Try to create shortcut to your application, define some path in shortcut property "Start in" and launch your application. The VisualC++ use the project file directory as current directory in debug mode, but it possible to change this behaviour in project/debbuging settings.
BTW you can retreive application exe path through ::GetModuleFileName() function.
ncode at 2007-11-9 13:31:34 >

# 2 Re: Does GetCurrentDirectory return the same path name of exe?
Hi,
I am making a simple app to get the full path name to the app and other files locate at the same directory. So I choose ::GetCurrentDirectory, but later I found what it retrieved is the directory where .vcproj resides, not the .exe. So I wonder if the app will correctly find where it is after distributed, and it adds much more difficulties to debug. Do you have any idea about it?
Thanks
Take a look at this FAQ (http://www.dev-archive.com/forum/showthread.php?t=312471) ;)