Read the IC card in Powerbulider
When writing the relevant information management system, there is sometimes problems such as reading and writing related external devices, such problems, implementing this type of functionality in Powerbulider is not a difficult thing, and now related external equipment manufacturers are providing products. Basically, the relevant programming interface is basically provided, and the ActiveX control after these interface functions can be easily implemented, and the basic code to read and write the IC card implementation is to eliminate the relevant programmer Fear of problems such as external equipment
External function declaration:
Subroutine Postpara (Long Prot, Strig Syspara) library "lock739.dll" // Parameters, mainly transmitting serial port information
Function Long Reset () library "lock739.dll" // read and write reset
Function Boolean Opencom () library "lock739.dll" // Open the serial port
Subroutine closecom () library "lock739.dll" // Close the serial port
Function long chkcard () library "lock739.dll" // check if the card is in place
Function Long Cmpsc (String SC) library "lock739.dll" // Check password
Function Long Writesc (String SC) library "lock739.dll" // Modify the encryption card password
Function Long Readsc (String Inbuff, Long Sclen) Library "LOCK739.DLL" // Si Qu encryption card password
Function Long Rddat (Long Cardtype, Long Start, Long Ilen, Ref String Inbuff) library "lock739.dll" // card reader information
Function Long Wrdat (Long Cardtype, Long Start, Long Ilen, Ref String Outbuff) library "lock739.dll" // write card information
Example variable:
Public String sc = '272272272'
Writing card function: wf_write (string as_arg1, long al_start, long al_len)
/ * Parameter string as_arg1 string written;
LONG Al_Start Writing Location
Long Al_Len Write the length * /
Long L_RTN
IF OpenCom () = false kil
MessageBox ("Tips", "Serial Port Connection Fail")
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 ("Tips", "Success!")
Card card function: wf_read (string as_arg1, long al_start, long al_len)
/ * Parameters String as_arg1 Save the string of the read information;
Long Al_Start starts reading the position of the LONG Al_len read the length of the card * /
Long L_RTN
IF OpenCom () = false kil
MessageBox ("Tips", "Serial Port Connection Fail")
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 ("Tips", "Reading Card Success!")
Display error function: wf_errorMessage (long lerror)
Choose Case Lerror
Case 1
MessageBox ("Tip", "Write error or password error!")
Case 2
MessageBox ("Tip", "Card is corrupt or parameter")
Case 3
MessageBox ("Tips", "Please insert your card!")
Case 4
MessageBox ("Tips", "Communication Error!")
Case Else
MessageBox ("Tips", "Unknown Error!")
End chaoose
Initialization card function WF_INITIALCARD (long al_port)
/ * Parameters: long al_port Incoming the serial port used by the reader * /
psotpara (al_port, "")
The IC card used by the above example code is the SLE4442 encrypted memory card, the card reader is WB1000 IC card reader
Through the example of the above code, the communication with external devices is not difficult, isn't it difficult? !