如何在 Delphi 中使用 TDataset 和 Dll
我想创建一个 dll 来从文件导入数据(不同格式,例如 csv、txt、xls...)。我的想法是这样的:dll 使用她的“引擎”加载数据,然后将此数据发送到我的应用程序,以便我的应用程序可以在网格内显示它们。
这是我的第二个 DLL,所以我有一些问题/疑问。
我认为我的 DLL 应该将数据发送到应用程序上的 TDataset,但是如何使用 TDataset 作为参数来调用 DLL?
有什么建议吗? 实现我的想法的最简单方法是什么? (如果可能的话)
I'd like create a dll to import data from a file (different format, for example csv, txt, xls, ...). My idea is this: the dll load the data with her "engine" then send this data to my application so my application can show them inside a grid.
This is my second DLL so I have some problems/questions.
I think my DLL should send the data to a TDataset on my application but how can I call a DLL with a TDataset as argument?
Any suggestions?
What is the easiest way to accomplish what I have in mind? (if possible)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您是这些 DLL 的创建者,请考虑使用包而不是 DLL。这将避免出现重复的 Delphi RTTI、普通 DLL API 等问题。然后,您需要在包之间正确拆分类,静态或动态加载包,获取对实现导入引擎的类的引用,并使用数据集引用作为参数值调用相应的方法。
If you are the creator of those DLL's, then consider to use packages instead of DLL. This will avoid the problems, like dublicate Delphi RTTI, plain DLL API. Then you will need to properly split classes between packages, load packages statically or dynamically, get reference to a class implementing import engine, and call the corresponding method with a dataset reference as a parameter value.
对您来说更简单的方法是将数据直接存储到 DLL 中的数据库中。导入后,您只需刷新 TDataset 即可。
顺便说一句,你不是“调用 DLL”,而是调用 DLL 中公开的一些方法,并且可以像普通方法一样使用参数。
编辑:对于不需要数据组件的更通用的 DLL,只需在结构中发送数据
Easier way for you would be to store the data directly into database in DLL. And after import you just refresh your TDataset.
BTW, you don't "call DLL", you call some method that is public in DLL and there you can use arguments as in normal methods.
EDIT: For more generic DLLs that don't require data components just send data in struct