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
(Visual Basic 6.0) ScMinidriver - Get Smartcard PropertiesSee more ScMinidriver ExamplesGets information about the smart card currently inserted in the reader (or USB token).
' This example requires the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim scmd As New ChilkatScMinidriver ' Reader names (smart card readers or USB tokens) can be discovered ' via PCSC List Readers or PCSC Find Smart Cards Dim readerName As String readerName = "Alcor Micro USB Smart Card Reader 0" Dim success As Long success = scmd.AcquireContext(readerName) If (success = 0) Then Debug.Print scmd.LastErrorText Exit Sub End If Dim json As New ChilkatJsonObject json.EmitCompact = 0 success = scmd.GetCardProperties(json) If (success = 0) Then Debug.Print scmd.LastErrorText Exit Sub End If Debug.Print json.Emit() ' 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 Dim strVal As String Dim bytesAvailable As Long bytesAvailable = json.IntOf("bytesAvailable") Dim containersAvailable As Long containersAvailable = json.IntOf("containersAvailable") Dim maxKeyContainers As Long maxKeyContainers = json.IntOf("maxKeyContainers") Dim capabilitiesFCertificateCompression As Long capabilitiesFCertificateCompression = json.BoolOf("capabilities.fCertificateCompression") Dim capabilitiesFKeyGen As Long capabilitiesFKeyGen = json.BoolOf("capabilities.fKeyGen") Dim keySizesMinimumBitlen As Long keySizesMinimumBitlen = json.IntOf("keySizes.minimumBitlen") Dim keySizesDefaultBitlen As Long keySizesDefaultBitlen = json.IntOf("keySizes.defaultBitlen") Dim keySizesMaximumBitlen As Long keySizesMaximumBitlen = json.IntOf("keySizes.maximumBitlen") Dim keySizesIncrementalBitlen As Long keySizesIncrementalBitlen = json.IntOf("keySizes.incrementalBitlen") Dim readOnly As Long readOnly = json.BoolOf("readOnly") Dim cacheMode As String cacheMode = json.StringOf("cacheMode") Dim supportsWinX509Enrollment As Long supportsWinX509Enrollment = json.BoolOf("supportsWinX509Enrollment") Dim guid As String guid = json.StringOf("guid") Dim serial As String serial = json.StringOf("serial") Dim pinUserType As String pinUserType = json.StringOf("pin.user.type") Dim pinUserPurpose As String pinUserPurpose = json.StringOf("pin.user.purpose") Dim pinUserCachePolicy As String pinUserCachePolicy = json.StringOf("pin.user.cachePolicy") Dim pinUserPolicyInfo As String pinUserPolicyInfo = json.StringOf("pin.user.policyInfo") Dim pinUserFlags As String pinUserFlags = json.StringOf("pin.user.flags") Dim pinUserAcceptPlainTextPin As Long pinUserAcceptPlainTextPin = json.BoolOf("pin.user.acceptPlainTextPin") Dim pinUserGenerateSessionPin As Long pinUserGenerateSessionPin = json.BoolOf("pin.user.generateSessionPin") Dim pinAdminType As String pinAdminType = json.StringOf("pin.admin.type") Dim pinAdminPurpose As String pinAdminPurpose = json.StringOf("pin.admin.purpose") Dim pinAdminCachePolicy As String pinAdminCachePolicy = json.StringOf("pin.admin.cachePolicy") Dim pinAdminPolicyInfo As String pinAdminPolicyInfo = json.StringOf("pin.admin.policyInfo") Dim pinAdminFlags As String pinAdminFlags = json.StringOf("pin.admin.flags") Dim pinRole3Type As String pinRole3Type = json.StringOf("pin.role3.type") Dim pinRole3Purpose As String pinRole3Purpose = json.StringOf("pin.role3.purpose") Dim pinRole3CachePolicy As String pinRole3CachePolicy = json.StringOf("pin.role3.cachePolicy") Dim pinRole3PolicyInfo As String pinRole3PolicyInfo = json.StringOf("pin.role3.policyInfo") Dim pinRole3Flags As String pinRole3Flags = json.StringOf("pin.role3.flags") Dim pinRole3AcceptPlainTextPin As Long pinRole3AcceptPlainTextPin = json.BoolOf("pin.role3.acceptPlainTextPin") Dim pinRole3GenerateSessionPin As Long pinRole3GenerateSessionPin = json.BoolOf("pin.role3.generateSessionPin") Dim pinRole4Type As String pinRole4Type = json.StringOf("pin.role4.type") Dim pinRole4Purpose As String pinRole4Purpose = json.StringOf("pin.role4.purpose") Dim pinRole4CachePolicy As String pinRole4CachePolicy = json.StringOf("pin.role4.cachePolicy") Dim pinRole4PolicyInfo As String pinRole4PolicyInfo = json.StringOf("pin.role4.policyInfo") Dim pinRole4Flags As String pinRole4Flags = json.StringOf("pin.role4.flags") Dim pinRole4AcceptPlainTextPin As Long pinRole4AcceptPlainTextPin = json.BoolOf("pin.role4.acceptPlainTextPin") Dim pinRole4GenerateSessionPin As Long pinRole4GenerateSessionPin = json.BoolOf("pin.role4.generateSessionPin") Dim i As Long i = 0 Dim count_i As Long count_i = json.SizeOfArray("pins") Do While i < count_i json.I = i strVal = json.StringOf("pins[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.user.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.user.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.user.unblockPermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.user.unblockPermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.admin.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.admin.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.role3.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.role3.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.role3.unblockPermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.role3.unblockPermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.role4.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.role4.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("importSupport") Do While i < count_i json.I = i strVal = json.StringOf("importSupport[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("algorithms") Do While i < count_i json.I = i strVal = json.StringOf("algorithms[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("paddingSchemes") Do While i < count_i json.I = i strVal = json.StringOf("paddingSchemes[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("chainingModes") Do While i < count_i json.I = i strVal = json.StringOf("chainingModes[i]") i = i + 1 Loop ' Delete the context when finished with the card. success = scmd.DeleteContext() If (success = 0) Then Debug.Print scmd.LastErrorText End If |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.