如何在 Delphi 中使用 TDataset 和 Dll

发布于 2024-12-05 21:40:22 字数 258 浏览 7 评论 0原文

我想创建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独夜无伴 2024-12-12 21:40:22

如果您是这些 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.

长梦不多时 2024-12-12 21:40:22

对您来说更简单的方法是将数据直接存储到 DLL 中的数据库中。导入后,您只需刷新 TDataset 即可。

顺便说一句,你不是“调用 DLL”,而是调用 DLL 中公开的一些方法,并且可以像普通方法一样使用参数。

编辑:对于不需要数据组件的更通用的 DLL,只需在结构中发送数据

 TMyData
 { int ID;
   String Value;
 };

int MyDataImport(TMyData & data)
{
...
}

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

 TMyData
 { int ID;
   String Value;
 };

int MyDataImport(TMyData & data)
{
...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文