Solved

DLL Questions Series, Part 5

Posted on 2000-03-24
3
203 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

746 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