0

我正在创建一个具有一百多个接口的 COM 类型库。在单个中定义所有接口和 coclasslibrary是不合理的...... IDL 文件变成了数千行!所以我尝试将每个接口放在自己的文件中,并使用imports 来满足其依赖关系。

我可以使用什么策略来管理这么多接口?我试图在import任何地方使用指令,但我一直试图将它们包含在 TLB 中。我已经尝试过#includelibrary但依赖项似乎变得很时髦。

示例A.idl

import "oaidl.idl", "ocidl.idl";
[ uuid(...) ] interface IExampleA : IDispatch { ... }

ExampleB.idl

import "oaidl.idl", "ocidl.idl", "IExampleA.idl";
[ uuid(...) ] interface IExampleB : IExampleA { ... }

示例库.idl

// Should I put some imports here? They won't be included in the library.
import "IExampleA.idl";
import "IExampleB.idl";

[ uuid(...) ]
library InfrastructureLib
{
    // This? Imports in a library don't actually include the types
    import "IExampleA.idl";
    import "IExampleB.idl";

    // Or this? I get class redefinition errors trying #include 
    #include "IExampleA.idl"
    #include "IExampleB.idl"

    // Is there another way?
};
4

1 回答 1

0

我认为您将接口拆分为多个 tlb 文件的计划很好,但是我不明白您为什么似乎是手动生成文件?

我的建议是将接口拆分为多个类型库,但使用类型库编辑器来创建它们。

每个版本的 Delphi 都有一个类型库编辑器,但如果你没有这个,网上应该有一些可用的。

于 2010-07-16T21:12:32.183 回答