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!

Very Simple C++ Question (no MFC)

Status
Not open for further replies.

lGOOODl

Programmer
Dec 4, 2001
31
DK
Hi,

How can I get the path were my program execute file i placed?

Thanks
..:::GOOOD:::..
 
Try to use this:

#include <direct.h>
.....
......
char Buffer[_MAX_PATH];// you can choose any other size that feet
_getcwd(Buffer,_MAX_PATH);
 
Is'nt there another way to do this, because this only shows were the program is opened from.
 
These might be what you looking for:

#include<windows.h>
#include<iostream.h>
....
......
char Buffer[_MAX_PATH];// you can choose any other size that feet
HINSTANCE hInstance = GetModuleHandle(NULL);
GetModuleFileName(hInstance, Buffer, MAX_PATH);
cout<< &quot;This program is: &quot;<<Buffer<<endl; // you can also use a 'MessageBox' to display this

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top