Smart Card Reader

Anyone tried using WinsCard.dll?

Based on SCardEstablishContext function (winscard.h) - Win32 apps

i have tried the following but get it wrong.

MODULE('WinScard.lib')

   SCardEstablishContext(LONG dwScope, LONG pvReserved1, LONG pvReserved2, *LONG phContext), LONG, PASCAL, NAME('SCardEstablishContextA')
    SCardListReaders(LONG hContext, LONG mszGroups, *CSTRING mszReaders, 
                     *LONG pcchReaders), LONG, PASCAL, NAME('SCardListReadersA')
    SCardReleaseContext(LONG hContext), LONG, PASCAL, NAME('SCardReleaseContext')

END

IF SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, hSC) = 0
MESSAGE('Context established successfully: ’ & hSC)
ELSE
MESSAGE(‘Failed to establish context’)
END

Have you tried using Zero (0) instead of NULL ?

hi rudy,
yes i modified the above code further:
SCardEstablishContext(LONG, LONG, LONG, *ULONG), LONG, PASCAL, RAW, NAME(‘SCardEstablishContext’)

and then replace null with zero…the compiler works. but when i run the code, i get the error -2146435055.
the reader automatically detected by the pc as Generic EMV SmartCard Reader 0

I have a class wrapper for WinSCard, but not for free.

Where you have *long in the prototype, these could be pointers to another pointer address, so it might be best to fire up the debugger and trace the addresses in memory to see what they eventually point to.

Or buy Mikes wrapper to save some time.

Mike made a class for me and it works.

1 Like