Page 1 of 1
Export classes from DLL

Posted:
October 1st, 2003, 2:41 pm
by jhynds
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.
Cheers
J

Posted:
October 1st, 2003, 5:31 pm
by Johnny_Bit
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.
Exporting classes in a DLL

Posted:
October 6th, 2003, 6:33 am
by Behrooz
Hi,
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)
type
TNamedClass = class
...
(in your dll)
type
TDefClass = class of Definition;
TDefinition = class(NamedClass)
...
end;
export GiveDefClass;
function GiveDefClass:TDefClass;
begin
return TDefinition;
end;
I'll send a documented sample code as soon as I can.