Click here to Skip to main content
13,297,878 members (46,599 online)
Click here to Skip to main content
Add your own
alternative version


50 bookmarked
Posted 5 Jun 2002

Exporting C++ classes without using MFC extension DLL

, 5 Jun 2002
Rate this:
Please Sign up or sign in to vote.
This article describes the process of exporting regular C++ classes without using MFC extension DLLs
<!-- Add the rest of your HTML here -->


DLLs are a great way of sharing common pieces of code data between applications. When it comes down to exporting C++ classes from DLLs most of us go for MFC extension DLLs where we can use the AFX_EXT_CLASS macro to export an entire class. Unfortunately, MFC is no lean and mean class architecture, which means that distributing MFC extension DLLs mean that you have to include the big MFC runtime not to mention the fact that your DLL can only be linked to MFC applications exclusively. What's the solution then? Enter standard Win32 DLLs.


I couldn't believe my eyes on how easily one can export C++ classes directly from a plain vanilla Win32 DLL. Just make one and insert your classes into the DLL. Now simply put __declspec(dllexport) in between the class keyword and the class name, i.e.

// in your header...

class __declspec(dllexport) CDllTest

  void SayHello();

// in your cpp...

void CDllTest::SayHello()
 printf(_T("Hello C++"));

That's it! The sample code and project are pretty self explanatory. Enjoy.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Tanzim Husain
Web Developer
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Questiondll Pin
mouass29-Mar-15 23:42
membermouass29-Mar-15 23:42 
QuestionI got lilnker error LN2019 Pin
Vivek_Mendse10-Nov-11 19:52
memberVivek_Mendse10-Nov-11 19:52 
QuestionReally - that simple? Pin
Vaclav_Sal4-Feb-11 9:48
memberVaclav_Sal4-Feb-11 9:48 
GeneralUsing dll Pin
s_t_r_e_a_m_e_r18-Nov-07 2:19
members_t_r_e_a_m_e_r18-Nov-07 2:19 
QuestionHow can I use a class exported from a DLL by using LoadLibrary function Pin
zhoujinjun085827-Aug-07 5:22
memberzhoujinjun085827-Aug-07 5:22 
AnswerRe: How can I use a class exported from a DLL by using LoadLibrary function Pin
afriza2-Dec-08 17:44
memberafriza2-Dec-08 17:44 
GeneralGreat! Pin
docrob125-Jan-07 18:48
memberdocrob125-Jan-07 18:48 
Generaldelete cuases access violation Pin
tom cruz18-Aug-05 3:35
membertom cruz18-Aug-05 3:35 
GeneralRe: delete cuases access violation Pin
Igen19-Mar-09 8:14
memberIgen19-Mar-09 8:14 
Generalqn Pin
From_Nepal6-Jan-05 9:00
sussFrom_Nepal6-Jan-05 9:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 6 Jun 2002
Article Copyright 2002 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid