Export classes from DLL

Please discuss general Delphi programming topics here.

Export classes from DLL

Postby jhynds » October 1st, 2003, 2:41 pm

I have several classes defined in an app and i want to be able to bundle them in a DLL and link to the Library to use the classes.
Can anyone suggest how i achieve this or point me towards a good tutorial/reference.

I also want to be able to use both threads and the win32 API in a DLL and am still unsure of the issues this will cause. A tutoiral for this would be great too.


Posts: 1
Joined: October 1st, 2003, 2:37 pm
Location: UK

Postby Johnny_Bit » October 1st, 2003, 5:31 pm

make sure that classes in aplication, and DLL are identical (maybe header file?) and from this point you can do whatever you like with classes.
VIP Member
VIP Member
Posts: 455
Joined: June 15th, 2003, 9:56 am

Exporting classes in a DLL

Postby Behrooz » October 6th, 2003, 6:33 am

A simple way for doing this is to write a unit that describes the class members and variables and let the procedures to be defined virtually (add the virtually keyword after defining a procedure or function) then use this unit in your DLL file and define a new class which inherites the named class, Last thing to be done is to define a function with result type of named class and return new class type and export this function. like this
(in first unit)
TNamedClass = class

(in your dll)
TDefClass = class of Definition;
TDefinition = class(NamedClass)

export GiveDefClass;

function GiveDefClass:TDefClass;
return TDefinition;

I'll send a documented sample code as soon as I can.
Active Member
Active Member
Posts: 5
Joined: October 6th, 2003, 6:11 am

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest