描述:
ATL中的IDL定义如下
typedef struct tagItemData
{
long x;
long y;
long z;
}ItemData;
[id(1), helpstring("method Test")] HRESULT Test([in]ItemData* iData);
编译后出现一个警告
warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'iData' of Procedure 'Test' ( Interface 'IIB' ) ]
忽略掉它,然后在vb6中调用这个方法
Public Type ItemData
x As Long
y As Long
z As Long
num As Long
End Type
调用代码如下
Dim id As ItemData
id.x = 3
id.y = 4
id.z = 5
id.num = 123
IB1.Test id
运行时错误
Compile error:
ByRef argument type mismatch
请问这是为什么,很奇怪
解决方案1:
凑热闹,我也遇到这样的问题,如果只是传递x,y,z,那我用3个long参数代替就可以了。
解决方案2: 你的组件如果有界面那就放弃这个念头,如果是简单接口,传递结构传递结构很简单在vb下直接定义该结构因为你idl中已经定义不必再在vb下定义这个结构
dim obj as new ItemData
......