Solved

Getting the App pointer

Posted on 1998-12-27
3
182 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

776 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