SCardWrappers v1.06 A set of a
set of C++ classes to provide a complete encapsulation of the Smart Card API for
The classes provided are: SCard::CException, SCard::CContext,
SCard::CContext2, SCard::CAPDURequest, SCard::CAPDUResponse, SCard::CCard,
SCard::CCard2, SCard::CATR, SCard::String, SCard::StringArray, SCard::GUIDArray &
CException is the exception class used and can be thrown by CContext2
and CCard2 methods. If MFC integration is chosen for the classes then this class
will be derived from the CException MFC class and exceptions will be thrown by pointer.
If STL integration is chosen then the exception will be throw by standard reference.
CContext provides an encapsulation of a Smart Card SCARDCONTEXT handle.
CContext2 derives from CContext and provides an exception based version
CAPDURequest provides a C++ encapsulation of a request which is sent to
the Transmit method of CCard/CCard2. It also provides a Parse method to convert
a raw BYTE buffer into a request.
CAPDUResponse provides a C++ encapsulation of a response which is received
via the Transmit method of CCard/CCard2. It also provides a Parse method to convert
a raw BYTE buffer into a response.
CCard provides an encapsulation of a Smart Card SCARDHANDLE handle.
CCard2 derives from CCard and provides an exception based version of it.
CATR provides an ATR parser class.
String derives from either CString if the classes are using MFC or std::string/std::wstring
if using STL.
StringArray derives from either CArray<String..> if the classes
are using MFC or std::vector<String> if using STL.
GUIDArray derives from either CArray<GUID..> if the classes are
using MFC or std::vector<GUID> if using STL.
ByteArray derives from either CByteArray if the classes are using MFC
or std::vector<BYTE> if using STL.
- Provides a simple C++ Header only module to easily encapsulate the Windows
Smart Card APIs.
- Integrates with the various STL's classes and MFC collection classes
for easier client coding. This is achieved internally in the various classes
through extensive use of the SCARD_AUTOALLOCATE Smart Card API support. These
various classes exposed in the API include SCard::String, SCard::StringArray,
SCard::GUIDArray and SCard::ByteArray.
The enclosed zip file contains the SCardWrappers
source code and a VC 2010 console based application which demonstrates most of the
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
V1.06 (12 November 2017)
- Renamed the CSCARDWRAPPERS_MFC_EXTENSIONS define to
"SCARDWRAPPERS_MFC_EXTENSIONS" to be consistent with the author's other
- Replaced CString::operator LPC*STR() calls with CString::GetString calls
- Replaced NULL with nullptr throughout the codebase. This means that the
code now requires VC 2010 at a minimum to compile.
- Replaced BOOL with bool throughout the codebase.
- Removed unnecessary AccessStartedEvent & ReleaseStartedEvent methods
- Updated parameters to CContext::GetProviderName &
CContext2::GetProviderName to match the SDK
- Removed redundant CCard & CCard2 methods which call CContext::GetAttrib
- Reviewed all the SAL annotations to make sure they are in sync with the
latest Windows 10 SDK
- Reviewed the code and made sure it supports everything in the latest
Windows 10 SDK
- Moved IntToHex, HexToInt, BinaryToString, AttributeBinaryToString,
AttributeBinaryStringToString, AttributeASCIIBinaryStringToString &
StringToBinary functions from SCardWrappers.h to the test.cpp demo app
30 April 2017
- Updated the demo app to compile cleanly using /permissive-.
V1.05 (25 March 2017)
- Updated copyright details.
- Updated code to compile cleanly on VC 2017
V1.04 (24 July 2016)
- Reworked the AttributeASCIIBinaryStringToString function to avoid the need
to call the Win32 API MultiByteToWideChar. Instead now the code uses the ATL
V1.03 (2 January 2016)
- Updated copyright details.
- The code now uses wostringstream and ostringstream instead of basic_stringstream<wchar_t>
V1.02 (29 November 2015)
- Updated the code to compile cleanly on VC 2015
- Verified there were no changes to the Windows Smart Card API on Windows
- Added SAL annotations to the ListReaderGroups methods for the return value
V1.01 (5 April 2015)
- Updated copyright details
- Updated the code to compile cleanly on VC 2013
- Added SAL annotations to all the code
V1.0 (28 April 2013)