I was missing something. SCardLocateCards
returns as part of the strucutre the ATR of the smartcard, which can then be used in SCardListCards
:
SCARD_READERSTATE smartcardState[MAXIMUM_SMARTCARD_READERS];
result = SCardLocateCards (context, cardsList, smartcardState, readerCount);
if (result == SCARD_S_SUCCESS) {
int i;
for (i = 0; i < readerCount; i++)
{
if (SCARD_STATE_ATRMATCH & smartcardState[i].dwEventState) {
break;
}
}
result = SCardListCards (NULL, smartcardState[i].rgbAtr, NULL, NULL, cardName, &count);
if (result == SCARD_S_SUCCESS) {
// Cardname for CryptAquireContext in cardName
}
}
If anyone has a better route forward let me know - I think this is the only way though from what I can see.