Click to See Complete Forum and Search --> : How to get current working directory path?


ycong77
June 7th, 2000, 03:26 AM
Is there anyone can please help me?

Just a simple question. How can I get the pathname for my current directory I am working with that it is where I run my application from?

Thank you.

YC

Oleg Lobach
June 7th, 2000, 03:36 AM
Hi,
try this:

char szPath[MAX_PATH];
::GetModuleFileName(NULL,szPath,MAX_PATH);



Hope this helps,
Oleg.

Syelixn
June 7th, 2000, 03:38 AM
You can use the function < char *_getcwd( char *buffer, int maxlen )>

yaoliwei
June 7th, 2000, 03:45 AM
GetModuleFileName ()

I love Inter Milan very much !

ycong77
June 8th, 2000, 05:09 AM
But that is the Window supported pathname....

how about if I want to retrive pathname for dos environment.

Please help

ycong77
June 8th, 2000, 06:06 AM
Using CFileDialog will set the current working path to the directory(path) where we select the file.

How does this work?

Anybody can please tell me.


Yew Chye

Andreas Masur
June 8th, 2000, 03:51 PM
Hi, you can use two functions...first 'GetWindowFileName()' as all the other mentioned in their replies and twice 'GetCurrentDirectory()'. The first one gives you the complete path and the applications' name. The second one gives you only the working directory of your application.

Andreas Masur

I'm not looking for ratings but they'll tell me how useful my help is.

ycong77
June 8th, 2000, 09:10 PM
Dear Andreas,

Do you have any idea how to retrive the Dos pathname??

Please help

YC

Andreas Masur
June 9th, 2000, 05:30 PM
Hmmm...good question. I never tried it before. For the function 'GetModuleFileName()' microsoft provides this information:

Windows 95: The GetModuleFilename function will return long filenames when an application's version number is greater than or equal to 4.00 and the long filename is available. Otherwise, it returns only 8.3 format filenames.

So, I think it will depends on the version of the os. But I'm not sure at the moment. Sorry.

Andreas Masur

I'm not looking for ratings but they'll tell me how useful my help is.