访问另一个DLL中的类? [英] Accessing classes that are in another DLL?

查看:73
本文介绍了访问另一个DLL中的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以从另一个dll
中导出和使用类,我有2个dll,并且我试图访问两者之间的类,所以想知道是否可能。

Is there is a way of exporting and using classes from another dll, I have 2 dll's and I am trying to access classes in between, was wondering if this is possible.

推荐答案

有多种方法可以实现此目的,包括但不限于以下方法:

There are a variety of ways to achieve this, including but not limited to the following:


  1. 使用运行时软件包而不是DLL。然后,您可以使用其他模块中的任何类型,变量等。请注意,这会迫使您在所有模块中使用运行时程序包,并使用相同版本的Delphi编译所有模块。

  2. 继续使用DLL,但可以通过以下方式访问类型:接口而不是Delphi类。与类不同,接口可以跨DLL边界导出。

  3. 继续使用DLL,但是使用单元范围的过程和函数而不是类来访问类型。这将使您进入与Win32界面性质相同的界面。

在上述选项中,它们的排列顺序为减少便利。最方便的方法是使用运行时程序包,但这可能会给您带来不希望的约束,即所有模块都使用相同的Delphi版本进行编译。接口通常比Win32风格的接口更方便使用,但是在设置这种体系结构时可能会有更多的编程开销。您必须做出最适合自己需要的选择。

Of the above options, they are arranged in order of decreasing convenience. The most convenient is to use runtime packages but that may place an undesirable constraint on you that all modules are compiled with the same Delphi version. Interfaces are usually more convenient to consume than a Win32 style interface, but there may be more programming overhead in setting up such an architecture. You'll have to make the choice that you feel best suits your needs.

如果您可以避免一开始就使用单独的模块,而是将所有内容都构建为一个可执行文件文件,那无疑是最方便的方法。

If you can avoid using separate modules in the first place, and build everything into a single executable file, then that is far and away the most convenient approach.

这篇关于访问另一个DLL中的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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