Export (0) Print
Expand All
Expand Minimize

SCardUIDlgSelectCard function

The SCardUIDlgSelectCard function displays the smart card Select Card dialog box.

Syntax


LONG WINAPI SCardUIDlgSelectCard(
  _In_  LPOPENCARDNAME_EX pDlgStruc
);

Parameters

pDlgStruc [in]

Pointer to the OPENCARDNAME_EX structure for the Select Card dialog box.

Return value

If the function successfully displays the Select Card dialog box, the return value is SCARD_S_SUCCESS.

If the function fails, it returns an error code. For more information, see Smart Card Return Values.

Remarks

The SCardUIDlgSelectCard function provides a method for connecting to a specific smart card. When called, this function performs a search for appropriate smart cards matching the OPENCARD_SEARCH_CRITERIA member specified by the pDlgStruc parameter. Depending on the dwFlags member of pDlgStruc, this function takes the following actions.

ValueAction

SC_DLG_FORCE_UI

Connects to the card selected by the user from the smart card Select Card dialog box.

SC_DLG_MINIMAL_UI

Selects the smart card if only one smart card meets the criteria, or returns information about the user's selection if more than one smart card meets the criteria.

SC_DLG_NO_UI

Selects the first available card.

 

This function replaces GetOpenCardName. The GetOpenCardName function is maintained for backward compatibility with version 1.0 of the Microsoft Smart Card Base Components.

Examples

The following example shows how to display the smart card Select Card dialog box.


SCARDCONTEXT     hSC;
OPENCARDNAME_EX  dlgStruct;
WCHAR            szReader[256];
WCHAR            szCard[256];
LONG             lReturn;

// Establish a context.
// It will be assigned to the structure's hSCardContext field.
lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
                                NULL,
                                NULL,
                                &hSC );
if ( SCARD_S_SUCCESS != lReturn )
{
    printf("Failed SCardEstablishContext\n");
    exit(1);
}

// Initialize the structure.
memset(&dlgStruct, 0, sizeof(dlgStruct));
dlgStruct.dwStructSize = sizeof(dlgStruct);
dlgStruct.hSCardContext = hSC;
dlgStruct.dwFlags = SC_DLG_FORCE_UI;
dlgStruct.lpstrRdr = (LPSTR) szReader;
dlgStruct.nMaxRdr = 256;
dlgStruct.lpstrCard = (LPSTR) szCard;
dlgStruct.nMaxCard = 256;
dlgStruct.lpstrTitle = (LPSTR) "My Select Card Title";

// Display the select card dialog box.
lReturn = SCardUIDlgSelectCard(&dlgStruct);
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardUIDlgSelectCard - %x\n", lReturn );
else
    printf("Reader: %S\nCard: %S\n", szReader, szCard );

// Release the context (by SCardReleaseContext - not shown here).


Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Winscard.h

Library

Scarddlg.lib

DLL

Scarddlg.dll

Unicode and ANSI names

SCardUIDlgSelectCardW (Unicode) and SCardUIDlgSelectCardA (ANSI)

See also

OPENCARDNAME_EX

 

 

Community Additions

ADD
Show:
© 2014 Microsoft