• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Getting Residing Directory

Hi

I have written a MFC application (*.exe) whereby my program need to know which directory does it is residing at.....

Formerly, I have used GetCurrentDirectory() and it work well a while until I have invoke this application from another directory (e.g. setting the PATH environment)....

So any one pls tell me how to find out where my program (*.exe) reside in??? Pls show a simple example... thanks....

0
ymw3
Asked:
ymw3
1 Solution
 
cyrilbdtCommented:
see GetModuleFileName.

char buf[_MAX_PATH];
GetModuleFileName(NULL, buf, sizeof(buf));

hope this helps
0
 
ymw3Author Commented:
Thanks.... It's work!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now