开发者

Managing definitions in a COM type library with a lot of IDL interfaces

I'm creating a COM type library with over one hundred interfaces. Defining all of the interfaces and coclasses in a single library is unreasonable... the IDL file becomes thousands of lines long! So I'm trying the idea of putting each interface in its开发者_如何转开发 own file, and using imports to satisfy its dependencies.

What strategies can I use to manage this many interfaces? I'm trying to use import directives everywhere, but I'm stuck trying to get them included in the TLB. I've tried #include in the library, but things seem to get funky with dependencies.

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?
};


I think your plan to split up the interfaces into multiple tlb files is fine, however I dont understand why you appear to be generating the files by hand?

My suggestion would be to split the interfaces into multiple typelibraries but use a typelibrary editor to create them.

A type library editor comes with every version of Delphi, but if you dont have this there should be a few available on the net.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜