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
(DataFlex) PC/SC Find Inserted Smart CardsSee more SCard ExamplesGet detailed information about each reader including whether or not a smart card is currently inserted in the reader. (Also includes USB tokens.) Note: This functionality was introduced in Chilkat v9.5.0.87.
Use ChilkatAx-win32.pkg Procedure Test Handle hoScard Boolean iSuccess Variant vJson Handle hoJson String sName String sState String sVendorName String sSystemName String sCardAtr String sCardWindowsMiniDriver String sCardWindowsCryptoProvider String sCardWindowsKeyStorageProvider String sSerialNumber Integer i Integer iCount_i String sTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatSCard)) To hoScard If (Not(IsComObjectCreated(hoScard))) Begin Send CreateComObject of hoScard End // First establish a context to the PC/SC Resource Manager Get ComEstablishContext Of hoScard "user" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoScard To sTemp1 Showln sTemp1 Procedure_Return End // Get JSON containing information about the smartcards currently inserted into readers. // This also includes information about USB security tokens. Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get pvComObject of hoJson to vJson Get ComFindSmartcards Of hoScard vJson To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoScard To sTemp1 Showln sTemp1 Procedure_Return End Set ComEmitCompact Of hoJson To False Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // Here is sample output: // See below for sample code to parse the JSON. // You can see which readers have a card inserted by the "state". // If the state contains "present", then a card is inserted into the reader. // (USB tokens will typically always have a state containing "present") // Also, the ATR of the card inserted into the reader is indicated by "atr". // { // "reader": [ // { // "name": "Alcor Micro USB Smart Card Reader 0", // "state": "present,inuse", // "vendorName": "Alcor Micro", // "systemName": "Alcor Micro USB Smart Card Reader 0", // "card": { // "atr": "3B7F96000080318065B0855956FB120FFE829000", // "windows": { // "miniDriver": "AxaltoCM.dll", // "cryptoProvider": "Microsoft Base Smart Card Crypto Provider", // "keyStorageProvider": "Microsoft Smart Card Key Storage Provider" // } // } // }, // { // "name": "FS USB Token 0", // "state": "present,inuse", // "vendorName": "FS", // "serialNumber": "3F", // "systemName": "FS USB Token 0", // "card": { // "atr": "3B9F958131FE9F006646530534002571DF000000000012", // "windows": { // "miniDriver": "eps2003csp11", // "cryptoProvider": "Microsoft Base Smart Card Crypto Provider", // "keyStorageProvider": "Microsoft Smart Card Key Storage Provider" // } // } // }, // { // "name": "FT Java Token 0", // "state": "present", // "vendorName": "FT", // "serialNumber": "3F", // "systemName": "FT Java Token 0", // "card": { // "atr": "3BFC180000813180459067464A00642D70C172FEE0FE", // "windows": { // "miniDriver": "tagliov70px.dll", // "cryptoProvider": "Microsoft Base Smart Card Crypto Provider", // "keyStorageProvider": "Microsoft Smart Card Key Storage Provider" // } // } // }, // { // "name": "SCM Microsystems Inc. SCR33x USB Smart Card Reader 0", // "state": "present", // "vendorName": "SCM Microsystems Inc.", // "serialNumber": "333130303330", // "systemName": "SCM Microsystems Inc. SCR33x USB Smart Card Reader 0", // "card": { // "atr": "3BFC180000813180459067464A00641606F2727E00E0", // "windows": { // "miniDriver": "tagliov70px.dll", // "cryptoProvider": "Microsoft Base Smart Card Crypto Provider", // "keyStorageProvider": "Microsoft Smart Card Key Storage Provider" // } // } // }, // { // "name": "Yubico YubiKey OTP+FIDO+CCID 0", // "state": "present", // "vendorName": "Yubico", // "serialNumber": "3F", // "systemName": "Yubico YubiKey OTP+FIDO+CCID 0", // "card": { // "atr": "3BFD1300008131FE158073C021C057597562694B657940", // "windows": { // "miniDriver": "msclmd.dll", // "cryptoProvider": "Microsoft Base Smart Card Crypto Provider", // "keyStorageProvider": "Microsoft Smart Card Key Storage Provider" // } // } // } // ] // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Move 0 To i Get ComSizeOfArray Of hoJson "reader" To iCount_i While (i < iCount_i) Set ComI Of hoJson To i Get ComStringOf Of hoJson "reader[i].name" To sName Get ComStringOf Of hoJson "reader[i].state" To sState Get ComStringOf Of hoJson "reader[i].vendorName" To sVendorName Get ComStringOf Of hoJson "reader[i].systemName" To sSystemName Get ComStringOf Of hoJson "reader[i].card.atr" To sCardAtr Get ComStringOf Of hoJson "reader[i].card.windows.miniDriver" To sCardWindowsMiniDriver Get ComStringOf Of hoJson "reader[i].card.windows.cryptoProvider" To sCardWindowsCryptoProvider Get ComStringOf Of hoJson "reader[i].card.windows.keyStorageProvider" To sCardWindowsKeyStorageProvider Get ComStringOf Of hoJson "reader[i].serialNumber" To sSerialNumber Move (i + 1) To i Loop // Applications should always release the context when finished. Get ComReleaseContext Of hoScard To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoScard To sTemp1 Showln sTemp1 End End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.