Is there is a way of exporting and using classes from another dll, I have 2 dll's and I am trying to access classes in between, was wondering if this is possible.
Asked
Active
Viewed 338 times
1 Answers
3
There are a variety of ways to achieve this, including but not limited to the following:
- Use runtime packages rather than DLLs. Then you can use any types, variables, etc. from another module. Note that this forces you to use runtime packages in all of your modules, and to compile all of the modules with the same version of Delphi.
- Continue to use DLLs, but access the types via interfaces rather than Delphi classes. Interfaces, unlike classes, can be exported across DLL boundaries.
- Continue to use DLLs, but access the types using unit scope procedures and functions rather than classes. This would lead you to an interface of the same nature as the Win32 interface.
Of the above options, they are arranged in order of decreasing convenience. The most convenient is to use runtime packages but that may place an undesirable constraint on you that all modules are compiled with the same Delphi version. Interfaces are usually more convenient to consume than a Win32 style interface, but there may be more programming overhead in setting up such an architecture. You'll have to make the choice that you feel best suits your needs.
If you can avoid using separate modules in the first place, and build everything into a single executable file, then that is far and away the most convenient approach.

David Heffernan
- 601,492
- 42
- 1,072
- 1,490
-
@ David thanks for the answer, I am more interested in using Interfaces, can you please share more light on this approach. – Alec Jan 18 '16 at 10:31
-
There are a variety of options. You can export functions that create and return particular interfaces. Or you can go the whole hog and write a COM server DLL. – David Heffernan Jan 18 '16 at 10:36