Read and write IC card in Powerbulider

Source: Internet
Author: User
Tags functions interface reset return
Read and write IC card in Powerbulider
When writing related information management system, sometimes meet the problems such as reading and writing related external equipment, such problems, in powerbulider to achieve this kind of function is not difficult, now the relevant external equipment manufacturers in the provision of products, the basic provision of the relevant programming interface, Using these interface functions, the ActiveX control, combined with the call of external functions in Powerbulider, can easily realize the related functions, the following provides the basic code of reading and writing IC card implementation, in order to eliminate the relevant programmers to read and write external equipment and other issues of fear
external function declaration:
Subroutine Postpara (long Prot,strig Syspara) library "Lock739.dll"//Transfer parameters, mainly passing serial port information
Function long Reset () library "Lock739.dll"//read/write Reset
Function Boolean opencom () library "Lock739.dll"//Open serial port
subroutine closecom () library "Lock739.dll"//Close serial port
Function long Chkcard () library "Lock739.dll"/Check card is in place
Function long CMPSC (string sc) library "Lock739.dll"//Check Password
Function long Writesc (string sc) library "Lock739.dll"//Modify encryption card password
Function long READSC (string Inbuff,long sclen) Library "Lock739.dll"//Curvature Encryption card password
Function long Rddat (Long cardtype,long start,long ilen,ref string inbuff) Library "Lock739.dll"/Read card information
Function long Wrdat (Long cardtype,long start,long ilen,ref string outbuff) Library "Lock739.dll"/write card information
Instance variables:
public string sc= ' 272272272 '
Write-card function: Wf_write (string As_arg1,long al_start,long Al_len)
/* Parameter string as_arg1 the string written;
Long Al_start where to write
Long Al_len Write Length * *
Long L_rtn
If opencom () =false Then
MessageBox ("Prompt", "Serial Connection Failed")
Return
End If
L_rtn=chkcard ()
If L_rtn<>0 Then
Wf_errormessage (L_RTN)
Closecom ()
Return
End If
L_RTN=CMPSC (SC)//sc for password
If L_rtn<>0 Then
Wf_errormessage (L_RTN)
Closecom ()
Return
End If
L_rtn=wrdat (1,AL_START,AL_LEN,AS_AGR1)
If L_rtn<>0 Then
Wf_errormessage (L_RTN)
Closecom ()
Return
End If
MessageBox ("Prompt", "Write card success!")
Read-card function: Wf_read (string As_arg1,long al_start,long Al_len)
/* Parameter string AS_ARG1 The string that holds the read out information;
Long Al_start start reading the card in place
Long Al_len Read Card length * *
Long L_rtn
If opencom () =false Then
MessageBox ("Prompt", "Serial Connection Failed")
Return
End If
L_rtn=chkcard ()
If L_rtn<>0 Then
Wf_errormessage (L_RTN)
Closecom ()
Return
End If
L_rtn=rddat (1,AL_START,AL_LEN,AS_AGR1)
If L_rtn<>0 Then
Wf_errormessage (L_RTN)
Closecom ()
Return
End If
MessageBox ("Prompt", "Read card success!")
Display Error function: Wf_errormessage (long Lerror)
Choose Case Lerror
Case 1
MessageBox ("Hint", "Write error or password error!") ”)
Case 2
MessageBox ("Hint", "card is corrupted or parameters are out of bounds!") “)
Case 3
MessageBox ("Hint", "Please insert card!") ”)
Case 4
MessageBox ("Hint", "Communication error!") ”)
Case Else
MessageBox ("Hint", "Unknown Error!") ”)
End Choose
Initialization card function Wf_initialcard (long al_port)
/* Parameter: Long al_port incoming reader using the serial port * *
Psotpara (Al_port, "")

The above example code uses the IC card for sle4442 encryption memory card, card reader for wb1000 IC card reader
Using the example above to achieve communication with external devices is not a difficult time?!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.