Smart Card User Interface
Following are two ways you can use the common dialog box. Both assume that the dialog box UI will be displayed. For more information, see OPENCARDNAME.
To select a smart card to open
- Declare a variable of type OPENCARDNAME.
- Provide enough information in the common dialog box to narrow the search for a smart card that the calling application is looking for. This includes specifying lpstrGroupNames, lpstrCardNames, and rgguidInterfaces. This also includes specifying a preferred share mode and protocol to use when the common dialog box connects to the card by using the dwShareMode and dwPreferredProtocols members of the OPENCARDNAME structure.
- Call the GetOpenCardName function to display the common dialog box to the user. A simple help information line will be displayed, and if one of the cards being requested is found, the card will be highlighted in the display. For multiple card name searches, the first reader that contains one of the preferred cards will be highlighted.
- The user then selects a card, clicks OK, and connects to the smart card.
To search for a specific card
Declare a variable of type OPENCARDNAME.
Provide enough information in the common dialog box to narrow the search for a smart card that the calling application is looking for. This includes specifying lpstrGroupNames, lpstrCardNames, and rgguidInterfaces.
Create the Connect, Check, and Disconnect callback functions, and set the lpfnConnect, lpfnCheck, and lpfnDisconnect data members appropriately.
All three functions and members must be available when using the common dialog box in this way.
Call the GetOpenCardName common dialog box function.
The common dialog box will then search for the requested cards. If a matching card name or ATR string is found, the Connect, Check, and Disconnect callback functions will be called in sequence. If a card passes the Check routine (that is, the Check callback returns TRUE), this card is highlighted in the display to the user.
If multiple card names are given, the first reader that contains one of the requested cards and passes the Check routine will be the selected card.
If no matches are found, a common dialog box will appear.