日期:2014-05-18  浏览次数:20915 次

帮忙看下!!
给的文档是这样
__int16 dc_pro_commandlink(HANDLE ICDev,unsigned char slen,unsigned char * sbuff,unsigned char *rlen,unsigned char * rbuff,unsigned char tt,unsigned char FG)
C# 程序是这样
public static extern int dc_pro_commandlink(int icdev, char slen, [Out] byte[] sbuff, [Out] byte[] rlen, [Out] byte[] rbuff, int tt, int FG);
但是发现偶尔会报错,请帮忙看看类型对吗谢谢。

------解决方案--------------------
加上调用约定试试

[DllImport("xxx"),CallingConvention.Cdecl]
------解决方案--------------------
报错说不定是接口自己报错呢,好好捉虫。看是不是条大虫
------解决方案--------------------
public static extern Int16 dc_pro_commandlink(IntPtr icdev, Byte slen, Byte[] sbuff, ref Byte rlen, Byte[] rbuff, Byte tt, Byte FG);
slen = sbuff.Length,用于输入数组大小
rlen用于输出rbuff数组大小,实参传入前须new
------解决方案--------------------
调用C++接口?
------解决方案--------------------
考虑下外部因素吧 既然你是偶尔报错的话