Estimados amigos,
Alguno de vosotros usa un lector de DNI electrónico ó compatible con tarjetas ISO 7816 ?
En caso afirmativo:
1. que hardware usais ?
2. Lo usais desde Harbour ?
3. Que API usais ?
gracias por la ayuda
#include <stdio.h>
#include <stdlib.h>
#include <winscard.h>
int main() {
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
DWORD dwReaders, dwActiveProtocol, dwReaderLen;
LONG lResult;
LPTSTR szReaders;
BYTE pbAtr[MAX_ATR_SIZE];
DWORD dwAtrLen;
// Establish a context to the PC/SC Resource Manager
lResult = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
if (lResult != SCARD_S_SUCCESS) {
printf("SCardEstablishContext failed with error: %08X\n", lResult);
return 1;
}
// Get the list of available readers
dwReaderLen = SCARD_AUTOALLOCATE;
lResult = SCardListReaders(hContext, NULL, (LPTSTR)&szReaders, &dwReaderLen);
if (lResult != SCARD_S_SUCCESS) {
printf("SCardListReaders failed with error: %08X\n", lResult);
SCardReleaseContext(hContext);
return 1;
}
printf("Available readers:\n%s\n", szReaders);
// Connect to the first reader in the list
lResult = SCardConnect(hContext, szReaders, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &hCard, &dwActiveProtocol);
if (lResult != SCARD_S_SUCCESS) {
printf("SCardConnect failed with error: %08X\n", lResult);
SCardFreeMemory(hContext, szReaders);
SCardReleaseContext(hContext);
return 1;
}
// Get the ATR of the card
dwAtrLen = sizeof(pbAtr);
lResult = SCardStatus(hCard, NULL, &dwReaderLen, &dwState, &dwActiveProtocol, pbAtr, &dwAtrLen);
if (lResult != SCARD_S_SUCCESS) {
printf("SCardStatus failed with error: %08X\n", lResult);
SCardDisconnect(hCard, SCARD_LEAVE_CARD);
SCardFreeMemory(hContext, szReaders);
SCardReleaseContext(hContext);
return 1;
}
printf("ATR of the card: ");
for (DWORD i = 0; i < dwAtrLen; i++) {
printf("%02X ", pbAtr[i]);
}
printf("\n");
// Disconnect from the card
lResult = SCardDisconnect(hCard, SCARD_LEAVE_CARD);
if (lResult != SCARD_S_SUCCESS) {
printf("SCardDisconnect failed with error: %08X\n", lResult);
}
// Release resources
SCardFreeMemory(hContext, szReaders);
SCardReleaseContext(hContext);
return 0;
}
#include "FiveWin.ch"
function Main()
MsgInfo( LoadLibrary( "winscard.dll" ) )
return nil
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 70 guests