Delphi and COM: Is it possible to pass TClientDataset to COM library as parameter?

I have a Delphi VCL application that manages a TClientDataset object. I need to pass this object as a parameter to a custom COM library also written in Delphi.

I have two questions: 1) Is this possible? 2) If so, how?

+3


source to share


1 answer


No, you cannot pass such an object. This is not a valid COM interop type. In fact, you cannot even pass such an object between Delphi modules, other than runtime packages.

The most obvious solutions are:



  • Wrap the object with a COM interface and pass it in. The interface will need to expose methods to retrieve the data.
  • Serialize the data as JSON for example and pass it as text. On the other hand, you will need to de-serialize.
  • Take advantage of the built-in serialization capabilities offered by the properties Data

    and XMLData

    client dataset.

The last two serialization based options are probably simpler. But more expensive in terms of memory. Using an interface requires more work to code, but can lead to more efficient runtime performance.

+3


source







All Articles