Talking to a SmartCard in FileMaker Pro
We had today some progress on talking to a SmartCard on Windows from FileMaker. Below the script which connects to the card and runs a query to figure out the version of the card:
If [MBS( "SmartCard.Available" ) = 1]
#Start a new session
Set Variable [$SCContext; Value:MBS( "SmartCard.Init" )]
If [MBS( "SmartCard.Valid"; $SCContext )]
#Query list of readers and pick first
Set Variable [$SCReader; Value:GetValue ( MBS( "SmartCard.ListReaders"; $SCContext) ; 1 )]
If [MBS("IsError") = 0]
#Connect to card
Set Variable [$SCConnect; Value:MBS( "SmartCard.Connect"; $SCContext ; $SCReader ; "Shared"; "any")]
Set Variable [$PRotocol; Value:MBS( "SmartCard.GetActiveProtocol"; $SCContext)]
If [$SCConnect = "OK"]
#Run a query
Set Variable [$Result; Value:MBS( "SmartCard.Transmit"; $SCContext; "0200000008000000"; "00ca018202"; 512 )]
#Result is 4 bytes. Starts with C901 for Version 5.0 or C903 for Version 5.3
Show Custom Dialog ["Version"; $result]
#Disconnect
Set Variable [$SCDisconnect; Value:MBS( "SmartCard.Disconnect"; $SCContext; "Leave" )]
Else
Show Custom Dialog ["Error"; "No card available."]
End If
End If
#End Card Session
Set Variable [$SCRelease; Value:MBS( "SmartCard.Release" ; $SCContext )]
Else
Show Custom Dialog ["Error"; "Failed to initalize"]
End If
Else
Show Custom Dialog ["Error"; "No SmartCard API on this OS."]
End If