4

我在 delphi IDE 专家中工作,现在为了避免依赖问题,我正在考虑按照这些答案之一中的建议将这个专家重建为 dll 专家,现在我的专家(编译为 bpl)访问ScreenApplication全局变量(实例Delphi IDE),所以我想知道我是否将我的专家编译为 dll,我仍然可以访问这些变量,我也想知道which are the main differences between a bpl delphi expert and a dll delphi expert?

4

2 回答 2

5

Should I compile my wizard as a DLL or a Package? Packages are easier to load and unload without restarting the IDE (and hence easier to debug), but they can create unit naming conflicts in the IDE. Conflicts happen when the name a wizard's unit matches the name of a unit in another loaded design-time package. In this case, both packages can not be loaded at the same time. The recommended workaround is to prefix all of your unit names with a "unique" prefix. GExperts, for example, uses "GX_" as the name prefix for its units.

From this very good source about OTA: GExperts

于 2011-05-19T19:10:03.983 回答
1

当您访问一个全局变量时,这些变量将是您的 DLL 的全局变量,而不是主 BDS.exe 的全局变量。我不确定,但我认为如果您在 Forms 和 VCL 的核心中链接,您的 DLL 将有自己的 Screen 和 Application 全局变量。

那些属于 IDE 本身的东西是通过 Open Tools Api (OTA) 访问的。我相信无论如何,您通常不会在专家之间共享任何对象,如果您尝试这样做,那将是有问题的。您所做的任何绕过 OTA 的操作都将很容易以奇怪的方式被破坏,尤其是在 IDE 的未来版本中。

依赖问题当然是不使用基于 BPL 的包的一个重要原因,但我认为更大的原因是保持工具内部和 IDE 内部之间的完全分离。

请记住,DLL 目标与可执行目标一样,是静态链接的。这就是差异的核心。如果您的专家提供的功能仅使用合法的公共文档 OTA 接口,那么迁移到 DLL 应该没有问题。如果您使用 BPL 可能的一些后门黑客,那么我无法进一步建议您。

于 2011-05-19T18:34:51.817 回答