SCardWrappers v1.14 A set of C++ classes to provide a complete encapsulation of the Smart Card API for
Windows
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 &
SCard::ByteArray.
CException is the exception class used and can be thrown by CContext2
and CCard2 methods. This class
is derived from std::exception.
CContext provides an encapsulation of a Smart Card SCARDCONTEXT handle.
CContext2 derives from CContext and provides an exception based version
of it.
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 is a typedef for std::string/std::wstring.
StringArray is a typedef for std::vector<String>.
GUIDArray is a typedef for std::vector<GUID>.
ByteArray is a typedef for std::vector<BYTE>.
Features
- Provides a simple C++ Header only module to easily encapsulate the Windows
Smart Card APIs.
- Integrates with the various STL 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 2017 console based application which demonstrates most of the
classes functionality.
Copyright
- 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.
Updates
v1.14 (18 December 2023)
- Updated copyright details.
- Remove usage of __if_exists from module.
v1.13 (6 March 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
- Removed all code which used LoadLibrary and GetProcAddress.
16 August 2021
- Updated copyright details.
- Updated compiler settings to more modern
defaults.
v1.12 (12 April 2020)
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.11 (15 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.10 (10 September 2019)
- Fixed a number of compiler warnings when the code is compiled with VS
2019 Preview
v1.09 (21 April 2019)
- Updated copyright details
- Updated the code to clean compile on VC 2019
v1.08 (16 September 2018)
- Fixed a number of compiler warnings when using VS 2017 15.8.4
v1.07 (11 July 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Removed code which supported SCARDWRAPPERS_MFC_EXTENSIONS code path
v1.06 (12 November 2017)
- Renamed the CSCARDWRAPPERS_MFC_EXTENSIONS define to
"SCARDWRAPPERS_MFC_EXTENSIONS" to be consistent with the author's other
code.
- 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
from CContext
- 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
module.
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
class CA2T.
v1.03 (2 January 2016)
- Updated copyright details.
- The code now uses wostringstream and ostringstream instead of basic_stringstream<wchar_t>
and basic_stringstream<char>.
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
10.
- 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)