TobjectList between exe and DLL in Delphi

后端 未结 1 568
傲寒
傲寒 2020-12-22 01:03

can somebody confirm me that it is not possible to exchange between an exe and a dLL written in Delphi a pointer that contains a TobjectList?

Class definitio         


        
相关标签:
1条回答
  • 2020-12-22 02:00

    You cannot pass Delphi objects across a module boundary unless you are using runtime packages. So, between a DLL and an EXE, it is not possible.

    The reason for this restriction is that in order to pass objects across module boundaries you need to share the types between the modules. And that's not possible with a DLL and an EXE. The sharing of types between different modules is the primary functionality of runtime packages.

    The documentation explains the limitation like this:

    Libraries are significantly more limited than packages in what they can export. Libraries cannot export constants, types, and normal variables. That is, class types defined in a library will not be seen in a program using that library. To export items other than simple procedures and functions, packages are the recommended alternative. Libraries should only be considered when interoperability with other programming is a requirement.

    If you must use DLLs then you need to find some other way to interop. One good option is to use interfaces.

    0 讨论(0)
提交回复
热议问题