Xbase++
Xbase++
ScMinidriver - Change Smart Card PIN (or USB token PIN)
See more ScMinidriver Examples
Demonstrates how to change the PIN for a smart card or USB token.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oScmd
LOCAL cReaderName
LOCAL cCurrentPin
LOCAL cNewPin
LOCAL nRetval
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oScmd := CreateObject("Chilkat.ScMinidriver")
// Reader names (smart card readers or USB tokens) can be discovered
// via List Readers or Find Smart Cards
cReaderName := "Alcor Micro USB Smart Card Reader 0"
nSuccess := oScmd:AcquireContext(cReaderName)
IF (nSuccess == 0)
? oScmd:LastErrorText
oScmd:destroy()
RETURN
ENDIF
// If successful, the name of the currently inserted smart card is available:
? "Card name: " + oScmd:CardName
// Change the "user" PIN. (Typically, you'll always be using the "user" PIN.)
cCurrentPin := "0000"
cNewPin := "1234"
nRetval := oScmd:PinChange("user", cCurrentPin, cNewPin)
IF (nRetval == -1)
? "The PIN is already blocked."
oScmd:destroy()
RETURN
ENDIF
IF (nRetval == -2)
? "The PinChange function failed for some unanticipated reason"
? oScmd:LastErrorText
oScmd:destroy()
RETURN
ENDIF
IF (nRetval == 0)
? "PIN successfully changed."
ELSE
? "Current PIN is incorrect."
? "Number of attempts remaining = " + Str(nRetval)
ENDIF
oScmd:DeleteContext()
oScmd:destroy()