|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (AutoIt) PC/SC Get Card UIDSee more SCard ExamplesSends the APDU command to get a card's UID.
 ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oScard = ObjCreate("Chilkat.SCard") ; First establish a context to the PC/SC Resource Manager Local $bSuccess = $oScard.EstablishContext("user") If ($bSuccess = False) Then ConsoleWrite($oScard.LastErrorText & @CRLF) Exit EndIf ; Use your own smart card reader name here. $bSuccess = $oScard.Connect("ACS ACR122 0","shared","no_preference") If ($bSuccess = False) Then ConsoleWrite($oScard.LastErrorText & @CRLF) Exit EndIf ConsoleWrite("Connected reader: " & $oScard.ConnectedReader & @CRLF) ConsoleWrite("Active protocol: " & $oScard.ActiveProtocol & @CRLF) ConsoleWrite("ATR: " & $oScard.CardAtr & @CRLF) ConsoleWrite("Reader Status: " & $oScard.ReaderStatus & @CRLF) ; Send the APDU command 0xFF, 0xCA, 0x00, 0x00, 0x00 $oBdRecv = ObjCreate("Chilkat.BinData") $bSuccess = $oScard.TransmitHex($oScard.ActiveProtocol,"FFCA000000",$oBdRecv,32) If ($bSuccess = True) Then ConsoleWrite("Received: " & $oBdRecv.GetEncoded("hex") & @CRLF) ; The UID is the returned data without the final 2 bytes. Local $iNumBytes = $oBdRecv.NumBytes If ($iNumBytes > 2) Then ConsoleWrite("UID: " & $oBdRecv.GetEncodedChunk(0,$iNumBytes - 2,"hex") & @CRLF) EndIf Else ConsoleWrite($oScard.LastErrorText & @CRLF) EndIf ; Disconnect from this reader. $bSuccess = $oScard.Disconnect("leave") If ($bSuccess = False) Then ConsoleWrite($oScard.LastErrorText & @CRLF) EndIf ; Applications should always release the context when finished. $bSuccess = $oScard.ReleaseContext() If ($bSuccess = False) Then ConsoleWrite($oScard.LastErrorText & @CRLF) EndIf | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.