GetCurrentDirectory is not working for real application path

  • Thread starter Thread starter Hasan O.
  • Start date Start date
H

Hasan O.

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
 
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
 
Back
Top