all groups > visual c > april 2006 >
You're in the

visual c

group:

GetCurrentDirectory is not working for real application path


GetCurrentDirectory is not working for real application path Hasan O.
4/28/2006 12:00:00 AM
visual c:
Hi ,

I have a simple program thats open some file a.txt. When program starts it
gets GetCurrentDirectory and finds / opens the a.txt file. But if i create
a shortcut on desktop it couldnot find real working directory. How can i do
this ?

this is not working for shortcuts
char buf[2001];
GetCurrentDirectory(2000, buf);
m_strCurrentDir = buf;

thanks in advance



Re: GetCurrentDirectory is not working for real application path Jochen Kalmbach [MVP]
4/28/2006 12:00:00 AM
Hi Hasan!

[quoted text, click to view]

It works perfectly for shortcuts!

But maybe you expected some other results as GetCurrentDirectory returns.
GetCurrentDirectory returns always the current directory. And for
shortcuts this is mostly "c:\windows\system32".

If you want to have the directory of your EXE, then you must use
"GetModuleFileName(NULL, ...)" and retrive the path from the returned
string.

Greetings
AddThis Social Bookmark Button