Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get program's runtime execution path?

Status
Not open for further replies.

programmer2002

Programmer
Apr 29, 2002
6
SG
Hi Gurus,

Would you please tell me how to get the program's runtime execution path using VC++/MFC? The path will be used to scan for files with certain extension.

Thanks in advance.
Lijun
 
Try this:

#include <windows.h>
#include <direct.h>
....
......
char Buffer[_MAX_PATH];// you can choose any other size that feet
HINSTANCE hInstance = GetModuleHandle(NULL);
GetModuleFileName( hInstance, Buffer, MAX_PATH );
// now the path of the concern program is stored in the string &quot;Buffer&quot;.

I hope that this will help !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top