Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ Current Directory

Started by Mr_Ridd Oct 11, 2004 at 4:06 AM 6 replies 1.8k views
Original Post
Mr_Ridd
Mr_Ridd
Hey How do I get the current directory I'm working in, in C++? I've seen a function called getcurdir() or something like that, which is found in dir.h. I've using Visual Stuio 6 and there is no dir.h? Is there another way to get it? Thanks
The ability to succeed is the ability to adapt
a2ps
a2ps
just use GetModuleFileName from the win32 API

something like:

char lpFilename[255];
memset( lpFilename, 0, 255 );
GetModuleFileName( AfxGetInstanceHandle(),lpFilename, MAX_PATH );

should do it.
yet, another stupid signature..
Mr_Ridd
Mr_Ridd
Thanks

-----
a2ps

Do I have to include anything to use those functions?

------
Anonymous Poster

It says in the reference that direct.h includes dir.h. I don't have dir.h though?
The ability to succeed is the ability to adapt
beefsteak
beefsteak
What about "GetCurrentDirectory"?
I've used that some times to get my app's directory and it worked well. AFAIK, the function doesn't bring any dependencies other than "windows.h".

Mr_Ridd
Mr_Ridd
This looks promising and the easiest. Just one thing though. Can I use it in a console app?
The ability to succeed is the ability to adapt
beefsteak
beefsteak
Should be no problem to call it from a console application.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.