以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  关于引用托管DLL文件的,求解?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=68844)

--  作者:youkacard
--  发布时间:2015/5/26 10:37:00
--  关于引用托管DLL文件的,求解?
怎么区分DLL是托管的还是非托管的,我这边买了个MW R6-U040的IC读卡器,添加DEMO里面的DLL显示已经添加,有点搞不明白
--  作者:大红袍
--  发布时间:2015/5/26 10:41:00
--  
 读卡器,一般都是非托管dll,具体要看人家给的开发文档怎么说。
--  作者:youkacard
--  发布时间:2015/5/26 10:50:00
--  
能帮我看下吗?开发包下载地址:http://device.mwcard.com/index.php?option=com_zoo&view=frontpage&Itemid=175

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20150526104919.jpg
图片点击可在新窗口打开查看


--  作者:大红袍
--  发布时间:2015/5/26 10:52:00
--  

 读卡器,都是非托管dll,直接拷贝到foxtable的安装目录下,参考

 

http://www.foxtable.com/help/topics/2664.htm

 


--  作者:youkacard
--  发布时间:2015/5/26 11:09:00
--  
1) INT32 __stdcall mw_dev_openReader(INT8 *name, HANDLE *devNo, UINT32 param1, UINT32 param2)
功能:打开读卡器通讯端口
参数:
Name :(A) 串行口读卡器可取"COM1", "COM2", "COM3", "COM4"等,字母大小写无关
(B) USB口读卡器可取"USB1", "USB2", "USB3", "USB4"等
devNo : 返回的通设备标识符
param1:(A) 串行口读卡器 波特率,9600/19200/57600/115200
(B) USB口读卡器打开设备的模式 1:共享模式 2:独占模式
param2:(A) 串行口读卡器校验位,可为\'E\' 偶校验, \'N\' 无校验,无特殊要求,一般使用偶校验即可
(B) USB口读卡器未使用,可设置为0
返回:=0 :成功
<>0 :失败

这个是开发文档的函数说明,那我在全局代码定义这样写:
Public Declare Function mwCardReader Lib "mwCardReader.dll" Alias "mwCardReader"(ByVal Name As String,ByVal devNo As String,ByVal param1 As Integer,ByVal param2 As Integer) \'打开通讯接口
这样写对不对
[此贴子已经被作者于2015/5/26 11:09:47编辑过]

--  作者:大红袍
--  发布时间:2015/5/26 11:11:00
--  
  你去打开人家 vb.net 的例子,看人家的代码是怎么写的。
--  作者:大红袍
--  发布时间:2015/5/26 11:12:00
--  

比如

 

 Declare Function mw_dev_openReader Lib "mwCardReader.dll" (ByVal name As String, ByRef devNo As Int32, ByVal param1 As UInt32, ByVal param2 As UInt32) As Int32
    Declare Function mw_dev_beep Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal beepTimes As Byte, ByVal interval As Byte, ByVal time As Byte) As Int32
    Declare Function mw_dev_reset Lib "mwCardReader.dll" (ByVal devNo As Int32) As Int32
    Declare Function mw_dev_closeReader Lib "mwCardReader.dll" (ByVal devNo As Int32) As Int32
    Declare Function mw_dev_readVer Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal readVer As String) As Int32
    Declare Function mw_mifare_openCard Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal openMode As Byte, ByVal cardUid As String) As Int32
    Declare Function mw_mifare_closeCard Lib "mwcardReader.dll" (ByVal devNo As Int32) As Int32
    Declare Function mw_mifare_authentication Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal mode As Byte, ByVal sector As UInt32, ByVal key As String) As Int32
    Declare Function mw_mifare_read Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal blockNO As UInt32, ByRef blockData As Byte) As Int32
    Declare Function mw_mifare_write Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal blockNO As UInt32, ByRef blockData As Byte) As Int32

    Declare Function mw_ext_ascToHex Lib "mwCardReader.dll" (ByVal asc As String, ByVal srcLen As Integer, ByRef hex As Byte) As Int32
    Declare Function mw_ext_hexToAsc Lib "mwCardReader.dll" (ByRef hex As Byte, ByVal srcLen As Integer, ByVal asc As String) As Int32

    Declare Function mw_cpu_reset Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal CardSeat As UInt32, ByRef returnData As Byte, ByRef arcLen As UInt16) As Int32
    Declare Function mw_cpu_apdu Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal cardSeat As UInt32, ByRef apduData As Byte, ByVal len As UInt32, ByRef returnData As Byte, ByRef relen As Int32) As Int32


--  作者:youkacard
--  发布时间:2015/5/26 11:31:00
--  
这些都要具备VB.NET的知识才能使用啊图片点击可在新窗口打开查看
--  作者:大红袍
--  发布时间:2015/5/26 11:32:00
--  

 vb.net的语法就是foxtable的语法。

 

 你打开人家的例子,看看人家代码怎么写。


--  作者:youkacard
--  发布时间:2015/5/26 15:53:00
--  
您好,版主,按照您的指点,我参照了下开发包里VB.NET范例,打开设备这个函数我调用成功了,但是后续的参数怎么调用都是失败,您帮我看下是不是我写错了。
例如控制指示灯:
这是开发文档说明:
INT32 __stdcall mw_dev_led(HANDLE devNo, UINT8 ctrlInfo)
功能:指示灯控制
参 数:
devNo : mw_dev_openReader( )返回的设备描述符
ctrlInfo: 指示灯控制信息,长度1个字节,bit7对应指示灯1控制;bit6对应指示灯2控制,以此类推; 0关、1开
例如:
0x80: 绿灯亮,红灯灭
返 回: =0: 成功
<>0: 出错

这是全局代码引用的API代码:
Public Declare Function mw_dev_led Lib "mwCardReader.dll" (ByVal devNo As Int32, ByVal ctrlInfo As Byte) As Int32 \'指示灯控制

我在AfterLoad调用代码:
dim st as integer
dim devNo as string
st = mw_dev_led(devNo,1)
但是实际好像不对啊,那个绿灯不亮