我做了这样一个测试。
实现一个进程外组件CA,CA组件实现了IA接口。idl文件如下所示:
typedef
[
uuid(AE54A11B-45E8-4ce1-836D-04854C35E272)
]
enum enumFlushType
{
[helpstring("Flush input buffer")] FLUSH_INPUT_BUFFER=0x0000
}enumFlushType;
[
object,
uuid(C8C090A7-361B-4484-BBD7-81479B34F01A),
dual
]
interface ISerialPort : IDispatch
{
[id(1),helpstring("method OpenPort")] HRESULT OpenPort([in]byte port,[in]long baud,[out,retval]VARIANT_BOOL *pboolResult);
};
typedef
[
uuid(776DC9DD-B508-406a-AD64-595917CCE9B8)
]
struct testStruct
{
enumFlushType m_Type;
ISerialPort* m_pSerialPort;
}testStruct;
[
object,
uuid(B72EEFCB-D896-4E62-BACE-14C6720C3BDF),
dual pointer_default(unique),
oleautomation
]
interface IA: IDispatch
{
[id(1), helpstring("method test")] HRESULT test([in]enumFlushType type,[in]testStruct ts,[in]ISerialPort* pSP);
};
编译并注册后,我未提供单独的proxy/stub dll,该组件在客户端程序中调用正常,但这与MSDN所描述的不符。
MSDN说,只有一个接口的所有函数的参数和返回值数据类型均为oleautomation兼容类型时,才能使用oleaut32.dll进行列集散集。
但是test函数的前两个参数肯定不符合此要求,为什么也能在客户端成功调用CA组件实现的test方法呢?而且该方法执行正确。
是不是使用自定义结构体和自定义枚举以及任何从IDispatch派生的接口指针作为参数也是与oleautomation类型兼容的?
什么地方有权威的说明?谢谢啦!