Getting the App pointer

I am writting a dll.  How do I get a pointer to the CWinApp class of the main program?

I tried AfxGetApp, but that returned the info on the dll.
DanielJenkinsAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
If you need this info, 'GetModuleFileName()' will do the job for you whan you supply 'NULL' as the first parameter...
0
 
Tommy HuiEngineerCommented:
This doesn't necessarily always work because you don't know if the application that is using the DLL is using MFC or not. If you have source to both the EXE and the DLL, then you should provide a function in the DLL that allows the EXE to pass in the CWinApp pointer as a parameter.
0
 
DanielJenkinsAuthor Commented:
I don't know what applications will be using this DLL, it could be a Visual Basic App or a Visual C++ App.

The items I need are the applications path and executable name.
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.

All Courses

From novice to tech pro — start learning today.