Solved

DLL Questions Series, Part 5

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

856 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