This is my first attempt in using a card reader in C#, or basically anywhere.
I use ACS ACR122U PICC Interface 0
reader in Windows 7 64bit.
My first problem occurs when I tried to connect to the reader using
ModWinsCard.SCardConnect(hContext, cbReader.SelectedItem.ToString(), ModWinsCard.SCARD_SHARE_DIRECT, 0, ref hCard, ref Protocol);
It returns error code 6, but I googled and solved it by changing project's platform from Any CPU
to X86
.
Right after that I bumped to another issue, this time in controlling the reader.
I tried with :
_sentBuffer = new byte[]
{
0xFF,
0x00,
0x48,
0x00,
0x00
};
_receivedBuffer = new byte[10];
_receivedBuffer[0] = 0;
_returnCode = ModWinsCard.SCardControl(_hCard, _dwControlCode, ref _sentBuffer[0], _sentBuffer.Length, ref _receivedBuffer[0], _receivedBuffer.Length, ref bytesReturned);
The returned code is 1
, which is weird because I can't found it in the documentation.
Really need a hand in this.
Thanks !
I somehow have it solved by downloading the latest driver from the provider's website, with uninstalling the driver that is included in the driver CD.
Still wonder what does return 1 means though..