Hi
We provide source code for customer. the source code made based on WINSCARD API(Linux and Mac os x call PC/SC API).
https://github.com/FeitianSmartcardRead ... ple%20CodeWhen you want to do communication with card, there have a API called SCardConnect, check below:
https://msdn.microsoft.com/en-us/librar ... 73(v=vs.85).aspx
http://pcsclite.alioth.debian.org/api/g ... 0696a8d6a5LONG SCardConnect ( SCARDCONTEXT hContext,
LPCSTR szReader,
DWORD dwShareMode,
DWORD dwPreferredProtocols,
LPSCARDHANDLE phCard,
LPDWORD pdwActiveProtocol
)
Establishes a connection to the reader specified in * szReader.
Parameters
[in] hContext Connection context to the PC/SC Resource Manager.
[in] szReader Reader name to connect to.
[in] dwShareMode Mode of connection type: exclusive or shared.
SCARD_SHARE_SHARED - This application will allow others to share the reader.
SCARD_SHARE_EXCLUSIVE - This application will NOT allow others to share the reader.
SCARD_SHARE_DIRECT - Direct control of the reader, even without a card. SCARD_SHARE_DIRECT can be used before using SCardControl() to send control commands to the reader even if a card is not present in the reader. Contrary to Windows winscard behavior, the reader is accessed in shared mode and not exclusive mode.
[in] dwPreferredProtocols Desired protocol use.
0 - valid only if dwShareMode is SCARD_SHARE_DIRECT
SCARD_PROTOCOL_T0 - Use the T=0 protocol.
SCARD_PROTOCOL_T1 - Use the T=1 protocol.
SCARD_PROTOCOL_RAW - Use with memory type cards. dwPreferredProtocols is a bit mask of acceptable protocols for the connection. You can use (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) if you do not have a preferred protocol.
[out] phCard Handle to this connection.
[out] pdwActiveProtocol Established protocol to this connection.
Returns
Error code.
Return values
SCARD_S_SUCCESS Successful (SCARD_S_SUCCESS)
SCARD_E_INVALID_HANDLE Invalid hContext handle (SCARD_E_INVALID_HANDLE)
SCARD_E_INVALID_PARAMETER phCard or pdwActiveProtocol is NULL (SCARD_E_INVALID_PARAMETER)
SCARD_E_INVALID_VALUE Invalid sharing mode, requested protocol, or reader name (SCARD_E_INVALID_VALUE)
SCARD_E_NO_SERVICE The server is not running (SCARD_E_NO_SERVICE)
SCARD_E_NO_SMARTCARD No smart card present (SCARD_E_NO_SMARTCARD)
SCARD_E_NOT_READY Could not allocate the desired port (SCARD_E_NOT_READY)
SCARD_E_PROTO_MISMATCH Requested protocol is unknown (SCARD_E_PROTO_MISMATCH)
SCARD_E_READER_UNAVAILABLE Could not power up the reader or card (SCARD_E_READER_UNAVAILABLE)
SCARD_E_SHARING_VIOLATION Someone else has exclusive rights (SCARD_E_SHARING_VIOLATION)
SCARD_E_UNKNOWN_READER szReader is NULL (SCARD_E_UNKNOWN_READER)
SCARD_E_UNSUPPORTED_FEATURE Protocol not supported (SCARD_E_UNSUPPORTED_FEATURE)
SCARD_F_COMM_ERROR An internal communications error has been detected (SCARD_F_COMM_ERROR)
SCARD_F_INTERNAL_ERROR An internal consistency check failed (SCARD_F_INTERNAL_ERROR)
SCARD_W_UNPOWERED_CARD Card is not powered (SCARD_W_UNPOWERED_CARD)
SCARD_W_UNRESPONSIVE_CARD Card is mute (SCARD_W_UNRESPONSIVE_CARD)
1 SCARDCONTEXT hContext;
2 SCARDHANDLE hCard;
3 DWORD dwActiveProtocol;
4 LONG rv;
5 ...
6 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
7 rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED,
8 SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol);