How to use C ++ classes exported by dll in Delphi

Is there a way to use C ++ classes exported by win32 dll in Delphi for win32? Are there other ways to archive similar objects (COM, .NET, ...)?

+6
c ++ dll delphi
source share
2 answers

You cannot import a class. You can import only functions. Rudi Veltius wrote in detail on this subject. Although you cannot directly use the exported C ++ class, it describes a couple of methods to achieve the same effect:

  • "Smooth" the object, so there is no longer any object on the caller, just a pointer that is passed to the DLL along with other parameters for a number of functions that wrap the object's methods. Writing a wrapper is very simple, although it can be tiring.

  • Use pure virtual classes. Windows C ++ and Delphi compilers usually have the same VMT layouts, so if a C ++ class can be described by a list of pure virtual methods, you can create an equivalent Delphi declaration, do some type casting with the object pointer returned DLL, and continue.

The article provides complete examples of both methods.

+11
source share

You cannot use C ++ classes exported from a DLL, as far as I know in Delphi; you can use C functions and you can import COM classes into Delphi.

+4
source share

All Articles