Hi,
is there a way to use C++ classes exported by a win32 dll in Delphi for win32? Are there other ways to archieve similar things (COM, .NET, ...)?
Hi,
is there a way to use C++ classes exported by a win32 dll in Delphi for win32? Are there other ways to archieve similar things (COM, .NET, ...)?
You can't 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.
You can't import a class. You can only import functions. Rudy Velthuis has written at length on the topic. Although you can't directly use an exported C++ class, he describes a couple of techniques to achieve the same effect:
"Flatten" the object, so on the calling side there is no object anymore, just a pointer that gets passed to the DLL along with other parameters for a series of functions that wrap the object's methods. Writing the wrapper is very simple, although it can be tedious.
Use pure virtual classes. Windows C++ compilers and Delphi have generally the same VMT layouts, so if the 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 by the DLL, and proceed.
Complete examples of both ways are given in the article.