实际上,在大多数情况下tlbimp 会将接口转换为 coclass 的一个功能。具体来说,如果在 IDL 我有
interface IFirst {
}
interface ISecond {
HRESULT GetFirst( IFirst** );
}
coclass First {
interface IFirst;
}
然后 tlbimp 将看到这First
是唯一要实现的类IFirst
,因此它创建了一个 .NET 接口,其中interface IFirst
替换为class First
interface ISecond {
First GetFirst(); // co-class returned, not interface
}
这在某种程度上可能是有帮助的。
这怎么可能有用?我的意思是无论如何class First
都会有相同的方法interface IFirst
,所以它不会添加任何东西,所以如果没有这种转换,我可以interface IFirst
到处传递并获得完全相同的效果。这个转换有什么用?