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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing working dir question 1

Status
Not open for further replies.

scienzia

Programmer
Feb 21, 2002
160
0
0
IT
My program creates files, and everythig is ok when I launch the program normally. The problem is that if I use a link to launch it the files created are in the directory of the link...

How do I change the working directory to the one of the exe file???????
 
_getcwd
_chdir

these functions found in <direct.h> could help you...

hope this help
 
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 );
_chdir( Buffer );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top