In this article we are going to develop a Smart Card Library that will ease the development of Smart Card Applications using the Win32 SDK and/or MFC. This assumes that you’re familiar with Win32 and MFC. The library builds upon the available support for Smart Cards in Windows by providing an Object Oriented wrapper over the WinSCard API. One advantage of using this library is the layered approach, which isolates the core API’s available to non-Win32 conformant languages like java to access this library through JNI (Java Native Interfaces). If you’ve already developed some applications using the APIs exposed by WinSCard.dll then you’ll be well aware of the complexities involved and here is an attempt to ease them.
Writing a Smart Card Library - The CRegListDlg Class (Page 4 of 5 )
This class just presents a UI (user Interface) to select a reader from the installed readers. The readers displayed in this selection dialog are picked from the registry settings displayed above (Figure 2). For a snapshot of this UI element refer to figure 5.
You can modify the code to display the readers from an entirely different location or even an ini file. It's solely dependent on the requirements one may have. But as Microsoft implements t this way I thought it'd be better if I stick to the registry.
Figure 5:The CPCSCCommand class and Members
The CPCSCCommand Class
This class encapsulates an APDU object. That is it takes care of the data sent and received from the card. Although I've provided a CString override of the SendCommandToCard() method but I'd recommend using the CPCSCCommand class.
The members with the prefix m_ are the actual data units that constitute the APDU and the remaining methods just set or retrieve them. The code for this class is straightforward and you can take a look to get a better understanding.