Smart Card User Interface

The smart card user interface (UI) is a single common dialog box that lets the user specify or search for a smart card to open (that is, connect to and use in an application).

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

  1. Declare a variable of type OPENCARDNAME.
  2. 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.
  3. 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.
  4. The user then selects a card, clicks OK, and connects to the smart card.

To search for a specific card

  1. Declare a variable of type OPENCARDNAME.

  2. 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.

  3. Create the Connect, Check, and Disconnect callback functions, and set the lpfnConnect, lpfnCheck, and lpfnDisconnect data members appropriately.

    Note

    All three functions and members must be available when using the common dialog box in this way.

     

  4. Call the GetOpenCardName common dialog box function.

  5. 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.

    Note

    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.

     

  6. If no matches are found, a common dialog box will appear.