Attribute VB_Name = "Module1"
Option Explicit
Public DelayTime As Integer
Public DelayFlag As Boolean
Public Declare Function link_com Lib "icbala32.dll" (ByVal port%) As Integer
Public Declare Function unlink_com Lib "icbala32.dll" (ByVal port%) As Integer
Public Declare Function power_on Lib "icbala32.dll" () As Integer
Public Declare Function power_off Lib "icbala32.dll" () As Integer
Public Declare Function inq_status Lib "icbala32.dll" (ByVal status$) As Integer
Public Declare Function sel_page Lib "icbala32.dll" (ByVal page%) As Integer
Public Declare Function sel_card Lib "icbala32.dll" (ByVal cardtype%) As Integer
Public Declare Function chk_secret Lib "icbala32.dll" (ByVal cmd%, ByVal secret$) As Integer
Public Declare Function fuse Lib "icbala32.dll" () As Integer
Public Declare Function rd_card Lib "icbala32.dll" (ByVal cmd%, ByVal addrh%, ByVal addrl%, ByVal lenth%, ByVal rece$) As Integer
Public Declare Function wr_card Lib "icbala32.dll" (ByVal cmd%, ByVal addrh%, ByVal addrl%, ByVal lenth%, ByVal send$) As Integer
Public Declare Function rd_cardc Lib "icbala32.dll" (ByVal cmd%, ByVal addrh%, ByVal addrl%, ByVal lenth%, ByVal rece$) As Integer
Public Declare Function wr_cardc Lib "icbala32.dll" (ByVal cmd%, ByVal addrh%, ByVal addrl%, ByVal lenth%, ByVal send$) As Integer
Public Declare Function erase_card Lib "icbala32.dll" (ByVal cmd%, ByVal addrh%, ByVal addrl%, ByVal lenth%) As Integer
Public Declare Function sfchk_secret Lib "icdll32.dll" (ByVal mmy%, ByVal ffxh%) As Integer
Public Declare Function rd_bala Lib "icbala32.dll" (ByVal bala$) As Integer
Public Declare Function wr_bala Lib "icbala32.dll" (ByVal bala$) As Integer

'******************通讯命令******************************************************************
'打开串口 int WINAPI rf_init_com(int port,long baud);
Public Declare Function rf_init_com Lib "MasterRD.dll" (ByVal port&, ByVal baud&) As Long
'关闭串口 int WINAPI rf_ClosePort();
Public Declare Function rf_ClosePort Lib "MasterRD.dll" () As Long
'int WINAPI rf_beep(unsigned short icdev, unsigned char msec)
Public Declare Function rf_beep Lib "MasterRD.dll" (ByVal icdev%, ByVal msec As Byte) As Long


'******************************************MF1*****************************************
'int WINAPI rf_request(unsigned short icdev, unsigned char model, unsigned short *TagType);
Public Declare Function rf_request Lib "MasterRD.dll" (ByVal icdev%, ByVal model As Byte, _
               ByRef TagType%) As Long
               
'int WINAPI rf_anticoll(unsigned short icdev, unsigned char bcnt, unsigned char *ppSnr,
'unsigned char* pRLength);
'Public Declare Function rf_anticoll Lib "MasterRD.dll" (ByVal icdev%, ByVal bcnt As Byte, _
'               ByRef ppsnr As Byte, ByRef pRLength As Byte) As Long
               
'int WINAPI rf_select(unsigned short icdev,unsigned char *pSnr,unsigned char srcLen,
'unsigned char *Size);
'Public Declare Function rf_select Lib "MasterRD.dll" (ByVal icdev%, ByRef pSnr As Byte, _
'               ByVal srclen As Byte, ByRef size As Byte) As Long

'int WINAPI rf_M1_authentication2(unsigned short icdev,unsigned char model,unsigned char block,
'unsigned char *key);
'Public Declare Function rf_M1_authentication2 Lib "MasterRD.dll" (ByVal icdev%, ByVal model As Byte, _
'               ByVal block As Byte, ByRef key As Byte) As Long
               
'int WINAPI rf_M1_read(unsigned short icdev, unsigned char block, unsigned char *ppData,
'unsigned char *pLen);
'Public Declare Function rf_M1_read Lib "MasterRD.dll" (ByVal icdev%, ByVal block As Byte, _
 '              ByRef buff As Byte, ByRef pLen As Byte) As Long

'int WINAPI rf_M1_write(unsigned short icdev, unsigned char block, unsigned char *data);
'Public Declare Function rf_M1_write Lib "MasterRD.dll" (ByVal icdev%, ByVal block As Byte, _
'               ByRef buff As Byte) As Long

'int WINAPI rf_halt(unsigned short icdev);
'Public Declare Function rf_halt Lib "MasterRD.dll" (ByVal icdev%) As Long

'int WINAPI rf_get_model(unsigned short icdev,
'                              unsigned char  *pVersion,
'                              unsigned char  *pLen)

Public Declare Function rf_get_model Lib "MasterRD.dll" (ByVal icdev%, ByRef buff As Byte, ByRef length As Byte) As Long


'  BYTE WINAPI T55x7_Read(unsigned char length , unsigned char * Data )
Public Declare Function T55x7_Read Lib "MasterRD.dll" (ByRef length As Byte, ByRef buff As Byte) As Long
'int WINAPI Standard_Write(unsigned  char opcode ,unsigned char lock ,unsigned char * Data ,unsigned char block )
Public Declare Function Standard_Write Lib "MasterRD.dll" (ByVal opcode As Byte, _
           ByVal lockbit As Byte, ByRef buff As Byte, ByVal block As Byte) As Long
'Protected_Writer
Public Declare Function Protected_Write Lib "MasterRD.dll" (ByVal opcode As Byte, _
 ByRef password As Byte, ByVal lockbit As Byte, ByRef buff As Byte, ByVal block As Byte) As Long
'int WINAPI Wake_Up(unsigned char * PassWord)
Public Declare Function Wake_Up Lib "MasterRD.dll" (ByRef password As Byte) As Long
'int WINAPI Direct_Access(unsigned char opcode  ,unsigned char block)
Public Declare Function Direct_Access Lib "MasterRD.dll" (ByVal opcode As Byte, _
       ByVal block As Byte) As Long
'int WINAPI Direct_Access_PWD(unsigned char opcode ,unsigned char *PassWord ,
'                             unsigned char block)
Public Declare Function Direct_Access_PWD Lib "MasterRD.dll" (ByVal opcode As Byte, _
       ByRef password As Byte, ByVal block As Byte) As Long
'int WINAPI Reset_Command()
Public Declare Function Reset_Command Lib "MasterRD.dll" () As Long

Public Declare Function Page_Regular_Read Lib "MasterRD.dll" (ByVal opcode As Byte) As Long

'4100读写
Public Declare Function Read_Em4001 Lib "MasterRD.dll" (ByRef buff As Byte) As Long

Public status As String  '读写器状态
Public chksecyn As Byte  '是否正确核对密码
Public cardtype As String '选择了何种卡型
Public readcard As String


 
'int WINAPI Standard_Write(unsigned  char opcode ,unsigned char lock ,
'                           unsigned char * Data ,unsigned char block )
'int WINAPI Protected_Write(unsigned  char opcode ,unsigned char * PassWord ,
'                           unsigned char lock ,unsigned char * Data ,unsigned char block)
'int WINAPI Wake_Up(unsigned char * PassWord)
'int WINAPI Direct_Access_PWD(unsigned char opcode ,unsigned char *PassWord ,
'                             unsigned char block)
'int WINAPI Direct_Access(unsigned char opcode  ,unsigned char block)
'int WINAPI Page_Regular_Read(unsigned char opcode)
'int WINAPI Reset_Command()
'int WINAPI T55x7_Read(unsigned char * length , unsigned char * Data )
'int WINAPI Read_Em4001(unsigned char * Data )
 
