?
Solved

Getting Residing Directory

Posted on 1998-11-19
2
Medium Priority
?
249 Views
Last Modified: 2013-11-20
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
Comment
Question by:ymw3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
cyrilbdt earned 150 total points
ID: 1324962
see GetModuleFileName.

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

hope this helps
0
 

Author Comment

by:ymw3
ID: 1324963
Thanks.... It's work!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question