难以将整数数组传递为VARIANT *

时间:2013-12-19 21:51:14

标签: vb.net com variant

编辑:昨天我的帖子已被修改。

EDIT2 :我尝试过使用Marshal.GetNativeVariantForObject,但我仍然遇到同样的错误。请参阅以下修改后的代码......

从VB.NET代码中,我调用COM对象的方法并获取DISP_E_TYPEMISMATCH

Dim thisDispName As String
Dim ap1StreamName As Object
Dim ap1Temperature As Object
Dim ap1Pressure As Object
Dim iTemporary(1) As Integer
Dim ptrToAp1Temperature As IntPtr = IntPtr.Zero
Const SizeOfNativeVariant As Int32 = 16

iTemporary(0) = 3
iTemporary(1) = iTemporary(0)
ap1Pressure = iTemporary

ptrToAp1Temperature = System.Runtime.InteropServices.Marshal.AllocHGlobal(SizeOfNativeVariant)
System.Runtime.InteropServices.Marshal.GetNativeVariantForObject(ap1Pressure, ptrToAp1Temperature)

apGen.GetHeaterStreams(thisDispName, ap1StreamName, ap1Temperature, ap1Pressure)

我知道方法GetHeaterStreams定义如下(我知道,很老的类型......)

GetHeaterStreams(BSTR* dispName, VARIANT* streamName, VARIANT* temp, VARIANT* pressure);

认为(不太确定)将空Object传递给VARIANT*类型的参数是可以的。但是,我认为问题是将ap1Pressure Integer数组传递给VARIANT*类型的参数

0 个答案:

没有答案