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

跪求帮助!调用PCI-Dask.dll,里面有个方法的参数是out关键字,怎么调用该方法?
[DllImport("PCI-Dask.dll")]
public static extern short DI_ReadPort (ushort CardNumber, ushort Port, out uint Value);

我在C#代码里面调用改方法,
int Result,gIOCard;
long gSigInput;
Result = DASK.DI_ReadPort((ushort)gIOCard, (ushort)0,out (uint) gSigInput);
一直出现编译错误是:ref或out参数必须是可以赋值的变量!  
跪求大家帮助啊。紧急啊

------解决方案--------------------
ushort Result,gIOCard;
uint gSigInput;
Result = DASK.DI_ReadPort((ushort)gIOCard, 0,out gSigInput);

试一试
------解决方案--------------------
C# code
// 方法定义
[DllImport("PCI-Dask.dll")]
public static extern short DI_ReadPort(ushort CardNumber, ushort Port, ref uint Value);

// 调用
ushort gIOCard = 0;
uint gSigInput = 0;
short Result = DI_ReadPort(gIOCard, 0, ref gSigInput);