470,866 Members | 1,878 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,866 developers. It's quick & easy.

GetCurrentDirectory is not working for real application path

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


Apr 28 '06 #1
1 1491
Hi Hasan!
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


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
Jochen
Apr 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Dan | last post: by
8 posts views Thread by Hardy Wang | last post: by
3 posts views Thread by Maileen | last post: by
2 posts views Thread by tshad | last post: by
1 post views Thread by pb | last post: by
1 post views Thread by Mark B | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.