4

我有两个使用 ATL 和 Microsoft 的 IDL 编写的带有 COM 接口的类型库。我希望一个库中的接口从另一个库中的接口继承。

本质上,我想做 Steven 在如何使用 .tlb 类型在 VS C++ 中创建接口方法?. 唯一回答他的人似乎不明白这个问题。

这是我想做的,在代码中:


SomeLibrary DLL/TLB

ISomeInterface.idl

interface ISomeInterface : IDispatch { ... };

SomeLibrary.idl

import "ISomeInterface.idl";

library SomeLibrary
{
    interface ISomeInterface;
};

SomeOtherLibrary DLL/TLB

ISomeOtherInterface.idl

// What do I put here so that the MIDL compiler knows
// what to do when it encounters the ISomeInterface type?

interface ISomeOtherInterface : ISomeInterface { ... };

SomeOtherLibrary.idl

import "ISomeOtherInterface.idl";

library SomeOtherLibrary
{
    interface ISomeOtherInterface;
};

MIDLimport指令仅在导入 IDL 文件时有效,而我只有一个 DLL 和 TLB。我不能使用importlib,因为这只适用于library定义。MIDL 编译器不理解 Microsoft 的 C++ importimportidlimportlib属性。

该怎么办?

4

1 回答 1

2

如果您愿意引入手动步骤,您可以在 oleview 中打开 tlb 并通过这种方式获取生成的 .idl 文件。oleview.exe 位于 Windows SDK 的 bin 目录中,例如

  C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\oleview.exe
于 2010-07-19T21:30:54.297 回答