我正在创建一个有一百多个接口的COM类型库。在单个library中定义所有接口和coclasses是不合理的……IDL文件变得有数千行那么长!因此,我尝试将每个接口放在其自己的文件中,并使用import来满足其依赖关系。
我可以使用什么策略来管理这么多接口?我尝试在所有地方使用import指令,但我在尝试将它们包含在TLB中时被卡住了。我尝试过在library中使用#include,但是依赖项似乎变得很时髦。
ExampleA.idl
import "oaidl.idl", "ocidl.idl";
[ uuid(...) ] interface IExampleA : IDispatch { ... }ExampleB.idl
import "oaidl.idl", "ocidl.idl", "IExampleA.idl";
[ uuid(...) ] interface IExampleB : IExampleA { ... }ExampleLibrary.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?
};发布于 2010-07-17 05:12:32
我认为你将接口分割成多个tlb文件的计划很好,但是我不明白为什么你似乎要手动生成这些文件?
我的建议是将界面分成多个类型库,但使用类型库编辑器来创建它们。
每个版本的Delphi都附带一个类型库编辑器,但是如果你没有这个编辑器,网上应该有一些。
https://stackoverflow.com/questions/3267463
复制相似问题