Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2006

Tip: Looking for answers? Try searching our database.

dll with class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gabi - 12 Jul 2006 07:29 GMT
hi all,
i have some class with a few methods inside.
those method used by external program (as a dll).
how should i declare those class methods so i can use it  outside??
another question is it possible to declare the all class as import or export??

Thanks
Bruno van Dooren - 12 Jul 2006 08:30 GMT
> i have some class with a few methods inside.
> those method used by external program (as a dll).
> how should i declare those class methods so i can use it  outside??
> another question is it possible to declare the all class as import or export??

When you build the dll, you have to declare the class for export using
__declspec(dllexport).
When you use the dll, you have to declare the class with __declspec(dllimport)

You can use a construct like this:

#ifdef BUILDING_DLL
#define IMPEXP __declspec(dllexport)
#else
#define IMPEXP __declspec(dllimport)
#endif

class IMPEXP CMyClass
{
 //...
};

If you build the dll, you have to define BUILDING_DLL in your precompiled
header or your project settings, so the class will be exported.
when you use the dll, this macro should not be defined, and the class will
be imported.
of course you still have to link your app against the lib file of the dll so
that the linker knows where it can find the the class.

Signature

Kind regards,
   Bruno.
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.