3 #include <winpr/smartcard.h>
5 int TestSmartCardListReaders(
int argc,
char* argv[])
10 LPSTR mszReaders = NULL;
11 DWORD cchReaders = SCARD_AUTOALLOCATE;
16 lStatus = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &hSC);
18 if (lStatus != SCARD_S_SUCCESS)
20 printf(
"SCardEstablishContext failure: %s (0x%08" PRIX32
")\n",
21 SCardGetErrorString(lStatus), lStatus);
25 lStatus = SCardListReadersA(hSC, NULL, (LPSTR)&mszReaders, &cchReaders);
27 if (lStatus != SCARD_S_SUCCESS)
29 if (lStatus == SCARD_E_NO_READERS_AVAILABLE)
30 printf(
"SCARD_E_NO_READERS_AVAILABLE\n");
40 printf(
"Reader: %s\n", pReader);
41 pReader = pReader + strlen((CHAR*)pReader) + 1;
44 lStatus = SCardFreeMemory(hSC, mszReaders);
46 if (lStatus != SCARD_S_SUCCESS)
47 printf(
"Failed SCardFreeMemory\n");
50 SCardReleaseContext(hSC);