Solved

Getting the App pointer

Posted on 1998-12-27
3
181 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:DanielJenkins
3 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1181069
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
 

Author Comment

by:DanielJenkins
ID: 1181070
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
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1181071
If you need this info, 'GetModuleFileName()' will do the job for you whan you supply 'NULL' as the first parameter...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now