ic卡读写器:在PowerBulider中读写IC卡

在写相关信息管理系统时有时会遇见读写相关外部设备等问题这类问题在PowerBulider中实现这类功能并不是件难事现在相关外部设备厂商在提供产品时基本都提供了相关编程接口利用这些接口后ActiveXControl控件结合PowerBulider中外部可以轻松实现相关功能以下提供读写IC卡实现基本代码以期消除相关编程人员对读写外部设备等问题恐惧心理
外部声明:
Subroutine PostPara(long prot,strig syspara) library “lock739.dll”//传递参数主要传递串口信息
Function long Re library “lock739.dll”//读写复位
Function Boolean OpenCom library “lock739.dll”//打开串口
Subroutine CloseCom library “lock739.dll”//关闭串口
Function long ChkCard library “lock739.dll”//检查卡是否到位
Function long CmpSc( sc) library “lock739.dll”//核对密码
Function long WriteSc( sc) library “lock739.dll”//修改加密卡密码
Function long ReadSc( inbuff,long sclen) library “lock739.dll”//度曲加密卡密码
Function long RdDat(long cardtype,long start,long ilen,ref inbuff) library “lock739.dll”//读卡信息
Function long WrDat(long cardtype,long start,long ilen,ref outbuff)library “lock739.dll”//写卡信息
例子变量:
public sc=’272272272’
写卡:wf_write( as_arg1,long al_start,long al_len)
/*参数 as_arg1 写入串;
long al_start 写入位置
long al_len 写入长度*/
long l_rtn
opencom=false then
messagebox(“提示”,”串口连接失败”)

end
l_rtn=chkcard
l_rtn<>0 then
  wf_errormessage(l_rtn)
closecom

end
l_rtn=cmpsc(sc)//sc为密码
l_rtn<>0 then
wf_errormessage(l_rtn)
closecom

end
l_rtn=wrdat(1,al_start,al_len,as_agr1)
l_rtn<>0 then
  wf_errormessage(l_rtn)
closecom

end
messagebox(“提示”,”写卡成功!”)
读卡:wf_read( as_arg1,long al_start,long al_len)
/*参数 as_arg1 保存读出信息串;
long al_start 开始读卡入位置
long al_len 读卡长度*/
long l_rtn
opencom=false then
messagebox(“提示”,”串口连接失败”)

end
l_rtn=chkcard
l_rtn<>0 then
  wf_errormessage(l_rtn)
closecom

end
l_rtn=rddat(1,al_start,al_len,as_agr1)
l_rtn<>0 then
  wf_errormessage(l_rtn)
closecom

end
messagebox(“提示”,”读卡成功!”)
显示:wf_errormessage(long lerror)
choose lerror
1
messagebox(“提示”,”写入或密码!”)
2
messagebox(“提示”,”卡已损坏或参数越界!“)
3
messagebox(“提示”,”请插卡!”)
4
messagebox(“提示”,”通讯!”)

messagebox(“提示”,”未知!”)
end choose
化卡wf_initialcard(long al_port)
/*参数:long al_port 传入读写器使用串口*/
psotpara(al_port,””)

以上例子代码所使用ic卡为sle4442 加密存储器卡读卡器为wb1000 IC卡读写器
通过以上代码举例实现和外部设备通讯并不是件很难时吧?!
Tags:  ic卡读写程序 ic卡读写 ic卡读写器

延伸阅读

最新评论

发表评论