Question

I am creating a DLL in C++ to be used in a Delphi 7 project, this dll will use OpenMP and will replace some methods that already exist in the project, this in order to hopefully get a speed up in the application.

One of the functions is defined like this:

function ReplaceFunction(chain:String;functionTE:TEFunction):string;

The object functionTE is declared like this,

TEFunction = class(TObject)
  private
    FFunctionName: string;
    procedure SetFunctionName(const Value: string);
    function GetFunctionNameCapital: string;
  public
    Handle:THandle;
    Funcion:Pointer;
    FileName:string;
    ParamNumber:integer;
    Description:string;
    property FunctionNameCapital:string read GetFunctionNameCapital;
    property FunctionName:string read FFunctionName write SetFunctionName;
  end;

How can I pass an object of this class to the dll and use it?

Was it helpful?

Solution

How can I pass an object of this class to the dll and use it?

You cannot. Only Delphi code can consume Delphi classes. And even then, only code that uses the same instance of the runtime. Which requires runtime packages.

You'll need to expose the functionality in an interop friendly manner. Either plain C style functions, or a COM style interface are the obvious options.

And not only can you not pass that object, you also must not attempt to use Delphi native strings across an interop boundary. Again you need to use interop friendly types. For strings this includes C string (null-terminated arrays of characters) and the COM BSTR.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top