大家来看下vb.net 的dll调用的奇怪问题
使用vb2005dll中函数:__int16 __stdcall rf_anticoll(HANDLE icdev,unsigned char _Bcnt,unsigned long *_Snr); (返回0为正确)
vb2005调用:
(声明)Public Declare Function rf_anticoll Lib "UReaderDrv.dll" (ByVal icdev As Integer, ByVal _Bcnt As Byte, ByVal _Snr() As Byte) As Integer
(调用) Dim snr(3) As Byte
Dim rfAnti As Integer
rfAnti = rf_anticoll(icdev, 0, snr)
问题:rfAnti的返回值不为0,但是snr中传递的数据是正确的
是否我的调用出现了问题?
谢谢指教 --------------------编程问答-------------------- 看清楚: 函數: rf_anticoll 中 ByVal _Bcnt As Byte ‘字節
dll中 :unsigned char _Bcnt ’字符串
你的調用: rfAnti = rf_anticoll(icdev, 0, snr)
是整型數據。
你連引用函數的數據類型都不一致,錯了很正常!
--------------------编程问答-------------------- 如果這個是正確的的話:dll中函数:__int16 __stdcall rf_anticoll(HANDLE icdev,unsigned char _Bcnt,unsigned long *_Snr); (返回0为正确)
聲明應該為:
Public Declare Function rf_anticoll Lib "UReaderDrv.dll" (ByVal icdev As IntPtr, ByVal _Bcnt As string, ByVal _Snr As long) As Integer
'icdev 應該是窗體的一個句柄
补充:.NET技术 , VB.NET