Solved

DLL Questions Series, Part 5

Posted on 2000-03-24
3
207 Views
Last Modified: 2010-04-02
This is the fifth part of the series.
The Overview can be found at:
http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10294044 
The previous parts can be found at:
(1) http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10294050 
(2) http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10295050 
(3) http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=10296575 
(4) http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10296931 

This question consists of two complementing subjects:

(a) What changes if instead of creating Win32 DLL project I create MFC DLL project? What support is added? Can I add it manually to a Win32 DLL project?

(b) Is there any difference between importing/exporting members of MFC-derived classes from/into a DLL and "simple" (not MFC-derived) ones?
0
Comment
Question by:Lescha
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
xLs earned 50 total points
ID: 2655803
a) using the MFC Dll project does only mean that you get the mfc library included and that you can take full use of it. But..

b) ofcourse if you define MFC specific methods that for instance returns a CString object, you may have to use MFC in your win32 project when importing your DLL.
However you can still write extern proc's that does use mfc in the code but not in the function definition (just like normal DLL without MFC).



good luck
/T. Rizos

0
 
LVL 1

Author Comment

by:Lescha
ID: 2656303
xLs,

you forgot one other subquestion:

what support (in other words, what lines of code) do I have to add to a non-MFC-supporting project in order to force it to support MFC?

Also: what happens if I try to link to DLL which supports MFC when my application doesn't support it?
0
 
LVL 2

Expert Comment

by:xLs
ID: 2656966
right, well an example of how to add mfc support is the simple Win32 Console wizzard (with mfc).

the problem is that mfc will need a CWinApp to handle the instance internally, and this will probably force you to modify some of your existing code (especially the main()).

what i would do if you have an non mfc existing project is to try wrap as much as possible of mfc methods that you will need in your dll so it is not visible in your DLL definition..

however, as meantioned you can still use all mfc support in your dll and use the dll in a non mfc win32 project.
this only if you dont have any declarations of MFC type in your header. so you can still use MFC in your code.
example:


if you have
extern CString GetPath();

you cannot use this in a non mfc project since CString won't be included.

instead go for
extern void GetPath(char* str,int bufsize);



if this is unclear i could setup a simple project with an mfc dll and a non mfc project using it?

cheers
/T. Rizos


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

815 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

8 Experts available now in Live!

Get 1:1 Help Now