Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) PC/SC Check the Status of each Smart Card Reader (and USB token)See more SCard ExamplesDemonstrates how to list the smart card readers and USB tokens connected to the computer, and check the status of each. Note: This functionality was introduced in Chilkat v9.5.0.87.
integer li_rc oleobject loo_Scard integer li_Success oleobject loo_StReaders integer li_NumReaders integer i string ls_Reader // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Scard = create oleobject // Use "Chilkat_9_5_0.SCard" for versions of Chilkat < 10.0.0 li_rc = loo_Scard.ConnectToNewObject("Chilkat.SCard") if li_rc < 0 then destroy loo_Scard MessageBox("Error","Connecting to COM object failed") return end if // First establish a context to the PC/SC Resource Manager li_Success = loo_Scard.EstablishContext("user") if li_Success = 0 then Write-Debug loo_Scard.LastErrorText destroy loo_Scard return end if loo_StReaders = create oleobject // Use "Chilkat_9_5_0.StringTable" for versions of Chilkat < 10.0.0 li_rc = loo_StReaders.ConnectToNewObject("Chilkat.StringTable") li_Success = loo_Scard.ListReaders(loo_StReaders) if li_Success = 0 then Write-Debug loo_Scard.LastErrorText destroy loo_Scard destroy loo_StReaders return end if li_NumReaders = loo_StReaders.Count i = 0 do while i < li_NumReaders ls_Reader = loo_StReaders.StringAt(i) Write-Debug string(i) + ": " + ls_Reader // Connect to this reader. if loo_Scard.Connect(ls_Reader,"shared","no_preference") = 1 then // Check the status to get the reader state, active protocol, and card ATR (if a card is inserted). if loo_Scard.CheckStatus() = 1 then Write-Debug "ReaderStatus: " + loo_Scard.ReaderStatus Write-Debug "CardAtr: " + loo_Scard.CardAtr Write-Debug "ActiveProtocol: " + loo_Scard.ActiveProtocol else Write-Debug loo_Scard.LastErrorText Write-Debug "CheckStatus failed." end if // Disconnect from this reader. li_Success = loo_Scard.Disconnect("leave") else Write-Debug loo_Scard.LastErrorText Write-Debug "Connect failed." end if Write-Debug "---------------------------------------" i = i + 1 loop // Sample output: // 0: Alcor Micro USB Smart Card Reader 0 // ReaderStatus: specific // CardAtr: 3B7F96000080318065B0855956FB120FFE829000 // ActiveProtocol: T0 // --------------------------------------- // 1: Generic Smart Card Reader Interface 0 // ReaderStatus: specific // CardAtr: 3BFC180000813180459067464A00641606F2727E00E0 // ActiveProtocol: T1 // --------------------------------------- // 2: SCM Microsystems Inc. SCR33x USB Smart Card Reader 0 // ReaderStatus: specific // CardAtr: 3BDF96FF8131FE455A018048494443313158587300011B09 // ActiveProtocol: T1 // --------------------------------------- // Applications should always release the context when finished. li_Success = loo_Scard.ReleaseContext() if li_Success = 0 then Write-Debug loo_Scard.LastErrorText end if destroy loo_Scard destroy loo_StReaders |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.