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
(PureBasic) ScMinidriver - Get Smartcard PropertiesSee more ScMinidriver ExamplesGets information about the smart card currently inserted in the reader (or USB token).
IncludeFile "CkJsonObject.pb" IncludeFile "CkScMinidriver.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. scmd.i = CkScMinidriver::ckCreate() If scmd.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Reader names (smart card readers or USB tokens) can be discovered ; via PCSC List Readers or PCSC Find Smart Cards readerName.s = "Alcor Micro USB Smart Card Reader 0" success.i = CkScMinidriver::ckAcquireContext(scmd,readerName) If success = 0 Debug CkScMinidriver::ckLastErrorText(scmd) CkScMinidriver::ckDispose(scmd) ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::setCkEmitCompact(json, 0) success = CkScMinidriver::ckGetCardProperties(scmd,json) If success = 0 Debug CkScMinidriver::ckLastErrorText(scmd) CkScMinidriver::ckDispose(scmd) CkJsonObject::ckDispose(json) ProcedureReturn EndIf Debug CkJsonObject::ckEmit(json) ; Here is sample output: ; See below for sample code to parse the JSON. ; ; NOTE: Not all smart cards support all properties. ; The GetCardProperties method will return information for all properties supported by the card. ; { ; "bytesAvailable": 74752, ; "containersAvailable": 18, ; "maxKeyContainers": 20, ; "capabilities": { ; "fCertificateCompression": false, ; "fKeyGen": true ; }, ; "keySizes": { ; "minimumBitlen": 2048, ; "defaultBitlen": 2048, ; "maximumBitlen": 4096, ; "incrementalBitlen": 1024 ; }, ; "readOnly": false, ; "cacheMode": "global", ; "supportsWinX509Enrollment": true, ; "guid": "1201803d-03e6-772a-3d80-0112e6032a77", ; "serial": "e6032a773d800112e6032a77", ; "pins": [ ; "user", ; "admin", ; "role3", ; "role4" ; ], ; "pin": { ; "user": { ; "type": "regular", ; "purpose": "primaryCard", ; "changePermission": [ ; "user" ; ], ; "unblockPermission": [ ; "admin" ; ], ; "cachePolicy": "normal", ; "policyInfo": "00000000", ; "flags": "00000000", ; "acceptPlainTextPin": true, ; "generateSessionPin": false ; }, ; "admin": { ; "type": "challenge/response", ; "purpose": "administrator", ; "changePermission": [ ; "admin" ; ], ; "cachePolicy": "normal", ; "policyInfo": "00000000", ; "flags": "00000000" ; }, ; "role3": { ; "type": "regular", ; "purpose": "digitalSignature", ; "changePermission": [ ; "role3" ; ], ; "unblockPermission": [ ; "role4" ; ], ; "cachePolicy": "alwaysPrompt", ; "policyInfo": "00000000", ; "flags": "00000000", ; "acceptPlainTextPin": true, ; "generateSessionPin": false ; }, ; "role4": { ; "type": "regular", ; "purpose": "unblockOnly", ; "changePermission": [ ; "role4" ; ], ; "cachePolicy": "normal", ; "policyInfo": "00000000", ; "flags": "00000000", ; "acceptPlainTextPin": true, ; "generateSessionPin": false ; } ; }, ; "importSupport": [ ; "plainText", ; "rsaKeyest", ; "eccKeyest", ; "symmetric" ; ], ; "algorithms": [ ; "AES" ; ], ; "paddingSchemes": [ ; "block", ; "pkcs1", ; "pss", ; "oaep" ; ], ; "chainingModes": [ ; "ChainingModeCBC" ; ] ; } ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON strVal.s bytesAvailable.i = CkJsonObject::ckIntOf(json,"bytesAvailable") containersAvailable.i = CkJsonObject::ckIntOf(json,"containersAvailable") maxKeyContainers.i = CkJsonObject::ckIntOf(json,"maxKeyContainers") capabilitiesFCertificateCompression.i = CkJsonObject::ckBoolOf(json,"capabilities.fCertificateCompression") capabilitiesFKeyGen.i = CkJsonObject::ckBoolOf(json,"capabilities.fKeyGen") keySizesMinimumBitlen.i = CkJsonObject::ckIntOf(json,"keySizes.minimumBitlen") keySizesDefaultBitlen.i = CkJsonObject::ckIntOf(json,"keySizes.defaultBitlen") keySizesMaximumBitlen.i = CkJsonObject::ckIntOf(json,"keySizes.maximumBitlen") keySizesIncrementalBitlen.i = CkJsonObject::ckIntOf(json,"keySizes.incrementalBitlen") readOnly.i = CkJsonObject::ckBoolOf(json,"readOnly") cacheMode.s = CkJsonObject::ckStringOf(json,"cacheMode") supportsWinX509Enrollment.i = CkJsonObject::ckBoolOf(json,"supportsWinX509Enrollment") guid.s = CkJsonObject::ckStringOf(json,"guid") serial.s = CkJsonObject::ckStringOf(json,"serial") pinUserType.s = CkJsonObject::ckStringOf(json,"pin.user.type") pinUserPurpose.s = CkJsonObject::ckStringOf(json,"pin.user.purpose") pinUserCachePolicy.s = CkJsonObject::ckStringOf(json,"pin.user.cachePolicy") pinUserPolicyInfo.s = CkJsonObject::ckStringOf(json,"pin.user.policyInfo") pinUserFlags.s = CkJsonObject::ckStringOf(json,"pin.user.flags") pinUserAcceptPlainTextPin.i = CkJsonObject::ckBoolOf(json,"pin.user.acceptPlainTextPin") pinUserGenerateSessionPin.i = CkJsonObject::ckBoolOf(json,"pin.user.generateSessionPin") pinAdminType.s = CkJsonObject::ckStringOf(json,"pin.admin.type") pinAdminPurpose.s = CkJsonObject::ckStringOf(json,"pin.admin.purpose") pinAdminCachePolicy.s = CkJsonObject::ckStringOf(json,"pin.admin.cachePolicy") pinAdminPolicyInfo.s = CkJsonObject::ckStringOf(json,"pin.admin.policyInfo") pinAdminFlags.s = CkJsonObject::ckStringOf(json,"pin.admin.flags") pinRole3Type.s = CkJsonObject::ckStringOf(json,"pin.role3.type") pinRole3Purpose.s = CkJsonObject::ckStringOf(json,"pin.role3.purpose") pinRole3CachePolicy.s = CkJsonObject::ckStringOf(json,"pin.role3.cachePolicy") pinRole3PolicyInfo.s = CkJsonObject::ckStringOf(json,"pin.role3.policyInfo") pinRole3Flags.s = CkJsonObject::ckStringOf(json,"pin.role3.flags") pinRole3AcceptPlainTextPin.i = CkJsonObject::ckBoolOf(json,"pin.role3.acceptPlainTextPin") pinRole3GenerateSessionPin.i = CkJsonObject::ckBoolOf(json,"pin.role3.generateSessionPin") pinRole4Type.s = CkJsonObject::ckStringOf(json,"pin.role4.type") pinRole4Purpose.s = CkJsonObject::ckStringOf(json,"pin.role4.purpose") pinRole4CachePolicy.s = CkJsonObject::ckStringOf(json,"pin.role4.cachePolicy") pinRole4PolicyInfo.s = CkJsonObject::ckStringOf(json,"pin.role4.policyInfo") pinRole4Flags.s = CkJsonObject::ckStringOf(json,"pin.role4.flags") pinRole4AcceptPlainTextPin.i = CkJsonObject::ckBoolOf(json,"pin.role4.acceptPlainTextPin") pinRole4GenerateSessionPin.i = CkJsonObject::ckBoolOf(json,"pin.role4.generateSessionPin") i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(json,"pins") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pins[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"pin.user.changePermission") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pin.user.changePermission[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"pin.user.unblockPermission") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pin.user.unblockPermission[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"pin.admin.changePermission") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pin.admin.changePermission[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"pin.role3.changePermission") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pin.role3.changePermission[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"pin.role3.unblockPermission") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pin.role3.unblockPermission[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"pin.role4.changePermission") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"pin.role4.changePermission[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"importSupport") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"importSupport[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"algorithms") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"algorithms[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"paddingSchemes") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"paddingSchemes[i]") i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"chainingModes") While i < count_i CkJsonObject::setCkI(json, i) strVal = CkJsonObject::ckStringOf(json,"chainingModes[i]") i = i + 1 Wend ; Delete the context when finished with the card. success = CkScMinidriver::ckDeleteContext(scmd) If success = 0 Debug CkScMinidriver::ckLastErrorText(scmd) EndIf CkScMinidriver::ckDispose(scmd) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.