Importing interfaces in IDL from an external type library
I have two type libraries with COM interfaces that I wrote using ATL and Microsoft's IDL. I would like an interface in one library to inherit from an interface in the other.
Essentially, I would like to do the same thing that Steven described at How do I create interface methods using .tlb types in VS C++?. The only person who answered him did not seem to understand the question.
Here's what I'd like to do, in code:
SomeLibrary DLL/TLB
ISomeInterface.id开发者_运维技巧l
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;
};
The MIDL import
directive only works when importing IDL files, and I only have a DLL and TLB. I can't use importlib
because that only works within a library
definition. The MIDL compiler doesn't understand Microsoft's C++ import
, importidl
, and importlib
attributes.
What to do?
If you are willing to introduce a manual step, you can open the tlb in oleview and get a generated .idl file that way. oleview.exe lives in the bin dir of the Windows SDK, eg
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\oleview.exe
精彩评论