一个com控件,名字叫SSIConnect,其中的一个函数,在c#里调用总是报错。c++ 里面的函数如下:
long CSSIConnect::GetDecodeData(VARIANT* DecodeData, short Type, short* SSICode)
{
long result;
static BYTE parms[] =
VTS_PVARIANT VTS_I2 VTS_PI2;
InvokeHelper(0x11, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
DecodeData, Type, SSICode);
return result;
}
VB里面引用该控件,函数的定义为:
Function GetDecodeData(DecodeData, Type As Integer, SSICode As Integer) As Long
  Member of SSICONNECTLib.SSIConnect
调用语句为:
Private Sub SSIConnect1_DecodeDataAvailable(ByVal Length As Long)
Dim b As Long
Dim code As IntegerDim Data As Variantb = SSIConnect1.GetDecodeData(Data, vbString, code)
If b > 0 Then
DecodeData = Data
Else
DecodeData = "Zero Length Decode Data"
End IfEnd Sub
c#引用该控件,函数的定义为:
public virtual int GetDecodeData(ref object decodeData, short type, ref short sSICode)
  AxSSICONNECTLib.AxSSIConnect 的成员c# 调用该函数如下,红色字体为调用语句:
  private void axSSIConnect1_DecodeDataAvailable(object sender, AxSSICONNECTLib._DSSIConnectEvents_DecodeDataAvailableEvent e)
  {
  int status = 0;
  Int16 code = 0;
  object data = new object();  this.timer1.Enabled = false;
  try
  {
  status = axSSIConnect1.GetDecodeData(ref data, vbString, ref code);
  }
  catch (Exception ex) { }  if (status > 0)
  {
  this.textBoxDecodeData.Text = "The Barcode is: " + data.ToString();
  }
  else
  {
  textBoxDecodeData.Text = "Zero Length Decode Data";
  }
  this.timer1.Enabled = true;
  }中间那个参数vbstring是从vb里面来的,代表返回值是string类型,查了一下VB,用8代替,第一个参数data就是返回值。
现在总是报错,不知道是哪一个参数出了问题,该怎样改正,高手赐教。

解决方案 »

  1.   

    vbstring看不明白  在那出来的?
      

  2.   

            [DllImport("hqt32wc.dll", EntryPoint = "inquire",
                CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
            public static extern int inquire(ref string[] buffER);
      

  3.   

    inquire 这个函数是干嘛用的,和我的问题有关嘛? 请说的详细一些!
      

  4.   

    c++写的这个SSIConnect控件,是托管的吗?
    C#我印象中必须调用托管的Com
      

  5.   

    程序执行到该函数的时候,总是报错,如下:
    Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))