[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

DLL Questions Series, Part 5

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
Lescha
Asked:
Lescha
  • 2
1 Solution
 
xLsCommented:
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
 
LeschaAuthor Commented:
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
 
xLsCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now