1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#define API_ENTRY
#define TPROSC_ENTRY API_ENTRY
typedef LONG ( TPROSC_ENTRY* PtrFctTSCardEstablishContext) (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext);
typedef LONG ( TPROSC_ENTRY* PtrFctTSCardListReaders) (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders);
PtrFctTSCardEstablishContext adressSCardEstablishContext;
PtrFctTSCardListReaders adressSCardListReaders;
QLibrary oLib("winscard.dll");
adressSCardEstablishContext = (PtrFctTSCardEstablishContext)oLib.resolve("SCardEstablishContext");
adressSCardListReaders = (PtrFctTSCardListReaders)oLib.resolve("SCardListReadersA");
SCARDHANDLE m_handleSC;
unsigned long lRes;
DWORD ulLenReader;
char * m_szListReaders;
m_szListReaders = NULL;
m_handleSC = 0;
ulLenReader =0;
lRes=adressSCardEstablishContext (SCARD_SCOPE_USER , NULL, NULL, &m_handleSC);
if ( lRes==SCARD_S_SUCCESS) {
rc = adressSCardListReaders (m_handleSC, NULL, (LPSTR)m_szListReaders, &ulLenReader);
if ((int)SCARD_E_NO_READERS_AVAILABLE == rc)
{ ...
}
m_szListReaders = new char[ulLenReader +1];
memset(m_szListReaders, 0x00, sizeof(char)* (ulLenReader +1) );
rc = adressSCardListReaders (m_handleSC, (LPCSTR)NULL, (LPSTR)m_szListReaders, (LPDWORD)&ulLenReader
if ((int)SCARD_E_NO_READERS_AVAILABLE == rc)
{ ...
}
} |
Partager