TobjectList between exe and DLL in Delphi

旧时模样 提交于 2019-11-29 17:02:27

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!