Delphi中的exe和DLL之间的TobjectList [英] TobjectList between exe and DLL in Delphi

查看:124
本文介绍了Delphi中的exe和DLL之间的TobjectList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以有人确认我不可能在Delphi和DelL之间交换一个包含TobjectList的指针吗?

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 definition shared between DLL and EXE
TCMStack = CLASS(TObject)
PRIVATE
FEquipment: TCMEquipment;         /// equipement with associated constraints
FNbCoils: integer;                  /// coils used
FListeCoils: TCoilsList;            ///coil list associaed with a stack
....

在可执行代码中:

...
/// Transfer business information to optimisation module
/// fOptimisation is a instance of class 
fOptimisation.TransfererDonneesMetiersDansOptimisation(@TStack, LEVEL_OPTIM_1, false);

除了TobjectList

The content of @TStack in good except the TobjectList

推荐答案

除非使用运行时包,否则不能跨模块边界传递Delphi对象。所以,在DLL和EXE之间,这是不可能的。

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.

此限制的原因是为了跨模块边界传递对象,您需要在模块之间共享类型。这不是一个DLL和一个EXE。不同模块之间的类型共享是运行时程序包的主要功能。

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.

文档解释了这样的限制:


库比在他们可以导出
。库不能导出常量,类型和正常的
变量。也就是说,在使用该库的程序中,库中定义的类类型将不会被看到
。要导出除简单
程序和函数之外的项目,软件包是推荐的替代方案。
只有当需要与其他
编程的互操作性时才应考虑库。

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.

如果您必须使用DLL那么你需要找到一些其他的方式进行互操作。一个好的选择是使用界面。

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

这篇关于Delphi中的exe和DLL之间的TobjectList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆