Lua Requires Chilkat v9.5.0.87+
Lua
PC/SC List Smart Card Readers (and USB Tokens)
See more SCard Examples
Demonstrates how to list the smart card readers and USB tokens connected to the computer.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local scard = chilkat.SCard.new()
-- First establish a context to the PC/SC Resource Manager
local success = scard:establish_context("user")
if not success then
print(scard.last_error_text)
return
end
local stReaders = chilkat.StringTable.new()
success = scard:list_readers(stReaders)
if not success then
print(scard.last_error_text)
return
end
local numReaders = stReaders.count
local i = 0
while i < numReaders do
print(i .. ": " .. stReaders:string_at(i))
i = i + 1
end
-- Sample output:
-- 0: Alcor Micro USB Smart Card Reader 0
-- 1: FS USB Token 0
-- 2: FT Java Token 0
-- 3: SCM Microsystems Inc. SCR33x USB Smart Card Reader 0
-- 4: Yubico YubiKey OTP+FIDO+CCID 0
-- Applications should always release the context when finished.
success = scard:release_context()
if not success then
print(scard.last_error_text)
end