本示例使用读写器介绍:Android Linux RFID读写器NFC发卡器WEB可编程NDEF文本/智能海报
声明函数:
declare integer pcdbeep in OUR_MIFARE.dll integer xms
declare integer pcdgetdevicenumber in OUR_MIFARE.dll string @pdevicenumber
declare integer piccreadex in OUR_MIFARE.dll integer ctrlword,string @mypiccserial,integer myareano,integer authmode,string @mypicckey,string @mypiccdata
declare integer piccwriteex in OUR_MIFARE.dll integer ctrlword,string @mypiccserial,integer myareano,integer authmode,string @mypicckey,string @mypiccdata
declare integer piccchangesinglekey in OUR_MIFARE.dll integer ctrlword,string @mypiccserial,integer myareano,integer authmode,string @mypiccoldkey,string @mypiccnewkey
轻松读卡:
BLOCK0_EN = 1 &&读块0
BLOCK1_EN = 2 &&读块1
BLOCK2_EN = 4 &&读块2
NEEDSERIAL = 8 &&是否需要只对指定系列号的卡操作
EXTERNKEY =16 &&是否使用外部密码
NEEDHALT = 32 &&是否休眠本卡
myctrlword=BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY &&23
mypiccserial=space(4) && 声明4个字节存放卡号
myareano=8 && 读卡的扇区号
authmode=1 && 1表示认证A密码 0表示认证B密码
mypicckey=chr(255)+chr(255)+chr(255)+chr(255)+chr(255)+chr(255) &&卡片认证密码
mypiccdata=space(48) && 声明48个字节存放读卡数据
ans= piccreadex(myctrlword,@mypiccserial,myareano,authmode,@mypicckey,@mypiccdata)
if ans=0
aa=ASC(SUBSTR(mypiccserial,1,1))*256*256*256+ASC(SUBSTR(mypiccserial,2,1))*256*256+ASC(SUBSTR(mypiccserial,3,1))*256+ASC(SUBSTR(mypiccserial,4,1))
= MESSAGEBOX(' 操作成功! '+STR(aa),48,'提示:')
else
if ans=8
= MESSAGEBOX(' 请将卡放在感应区! ',48,'提示:')
ENDIF
if ans=12
aa=ASC(SUBSTR(mypiccserial,1,1))*256*256*256+ASC(SUBSTR(mypiccserial,2,1))*256*256+ASC(SUBSTR(mypiccserial,3,1))*256+ASC(SUBSTR(mypiccserial,4,1))
= MESSAGEBOX(' 密码认证失败! '+STR(aa),48,'提示:')
endif
endif
轻松写卡:
BLOCK0_EN = 1 &&读块0
BLOCK1_EN = 2 &&读块1
BLOCK2_EN = 4 &&读块2
NEEDSERIAL = 8 &&是否需要只对指定系列号的卡操作
EXTERNKEY =16 &&是否使用外部密码
NEEDHALT = 32 &&是否休眠本卡
myctrlword=BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY &&23
mypiccserial=space(4) && 声明4个字节存放卡号
myareano=8 && 写卡的扇区号
authmode=1 && 1表示认证A密码 0表示认证B密码
mypicckey=chr(255)+chr(255)+chr(255)+chr(255)+chr(255)+chr(255) &&卡片认证密码
mypiccdata=''
for i=1 to 48 &&写卡信息,每次写一个扇区共计48个字节
mypiccdata=mypiccdata+chr(255)
next i
ans= piccwriteex(myctrlword,@mypiccserial,myareano,authmode,@mypicckey,@mypiccdata)
if ans=0
= MESSAGEBOX(' 操作成功! ',48,'提示:')
else
if ans=8
= MESSAGEBOX(' 请将卡放在感应区! ',48,'提示:')
endif
endif
修改卡片密码:
myctrlword=0
mypiccserial=space(4)
myareano=8
authmode=1
mypiccoldkey=''
for i=1 to 6
mypiccoldkey=mypiccoldkey+chr(255)
next i
mypiccnewkey=''
for i=1 to 6
mypiccnewkey=mypiccnewkey+chr(255)
next i
ans=piccchangesinglekey(myctrlword,@mypiccserial,myareano,authmode,@mypiccoldkey,@mypiccnewkey)
if ans=0
= MESSAGEBOX(' 操作成功! ',48,'提示:')
else
if ans=8
= MESSAGEBOX(' 请将卡放在感应区! ',48,'提示:')
endif
endif