#include <stdio.h>
#ifdef __APPLE__
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#else
#include <winscard.h>
#endif
#define PCSC_ERROR_EXIT(rv) \
if (rv != SCARD_S_SUCCESS) \
{ \
printf("Failed at line %d with %s (0x%lX)\n", __LINE__, pcsc_stringify_error(rv), rv); \
goto end; \
}
int main(void)
{
LONG rv;
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
int value = -1, ret = -1;
DWORD dwReaders, dwPref;
char *mszReaders;
rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
PCSC_ERROR_EXIT(rv)
dwReaders = SCARD_AUTOALLOCATE;
rv = SCardListReaders(hContext, NULL, (LPSTR)&mszReaders, &dwReaders);
PCSC_ERROR_EXIT(rv)
printf("Using reader: %s\n", mszReaders);
rv = SCardConnect(hContext, mszReaders,
SCARD_SHARE_DIRECT, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&hCard, &dwPref);
PCSC_ERROR_EXIT(rv)
printf("ret: %d\n", ret);
printf("value for PCSCv2_PART10_PROPERTY_wIdVendor: 0x%04X\n", value),
rv = SCardDisconnect(hCard, SCARD_LEAVE_CARD);
PCSC_ERROR_EXIT(rv)
rv = SCardFreeMemory(hContext, mszReaders);
PCSC_ERROR_EXIT(rv)
rv = SCardReleaseContext(hContext);
PCSC_ERROR_EXIT(rv)
end:
return ret;
}
#define PCSCv2_PART10_PROPERTY_wIdVendor
Definition: PCSCv2part10.h:78
int PCSCv2Part10_find_TLV_property_by_tag_from_hcard(SCARDHANDLE hCard, int property, int *value)
Find a integer value by tag from a PC/SC card handle.