OWLNext 7.0
Borland's Object Windows Library for the modern age
|
A class instance in a DLL can be shared among multiple applications.
For example, you can share code that defines a dialog box by defining a shared dialog class in a DLL. The shared class can then be used in or derived from by other applications or DLLs. To share a class you need to export the class from the DLL and import the class into your application.
To define shared classes:
If you declare a shared class in an include file that is included by both the DLL and an application using the DLL, the class must be declared _export when compiling the DLL and _import when compiling the application. You can do this by defining a group of macros, one of which is conditionally set to _export when building the DLL and to _import when using the DLL. For example:
By defining BUILDEXAMPLEDLL (on the command line, for example) when you are building the DLL, you cause _EXAMPLECLASS to expand to _export. This causes the class to be exported and shared by applications using the DLL.
By defining USEEXAMPLEDLL when you are building the application that will use the DLL, you cause _EXAMPLECLASS to expand to _import. The application will know what type of object it will import.