Search code examples
delphidlloverridingvirtual

Passing a class containing overridden virtual methods to a dll


I have an application and a dll, both written in Delphi 2006.

I have an class that descends from a base class and overrides several virtual methods.

The class is passed to the DLL via an exported method, the exported method only knows about the base class. I call the methods on the class from within the DLL the overridden methods are not invoked.

Is there something I need to do to get this to work? is is it simply not possible?


Solution

  • You can't create an object in one module and call its methods in a different module. By module I mean .exe/.dll.

    If you wish to cross boundaries like this, then you need to use packages, COM or free functions. Packages look alluring but bind you into using the same compiler for all packages in the system. If that is not restrictive to you then go ahead and use packages. Otherwise use COM or free functions.