使用.Net技术开发智能卡读卡器

有谁知道如何监控智能卡的存在并读取卡的UID值?

是的我在网上尝试过很多例子

适用于.NET的智能卡框架

PCSC锐

监控智能卡读卡器

但不知道该怎么做。 我可以检测卡的存在并且可以单独获取UID,但不知道如何在我的应用程序中组合它们:(。

帮我

我明白了。 想与有兴趣的人分享。

我使用winscard.dll函数来访问卡数据并与PC通信。

请注意,我使用Mifare 1K卡作为NFC标签和读卡器ACR 122u

private string getcardUID()//only for mifare 1k cards { string cardUID = ""; byte[] receivedUID = new byte[256]; Card.SCARD_IO_REQUEST request = new Card.SCARD_IO_REQUEST(); request.dwProtocol = Card.SCARD_PROTOCOL_T1; request.cbPciLength = System.Runtime.InteropServices.Marshal.SizeOf(typeof(Card.SCARD_IO_REQUEST)); byte[] sendBytes = new byte[] { 0xFF, 0xCA, 0x00, 0x00, 0x00 }; //get UID command for Mifare cards int outBytes = receivedUID.Length; int status = Card.SCardTransmit(hCard, ref request, ref sendBytes[0], sendBytes.Length, ref request, ref receivedUID[0], ref outBytes); if (status != Card.SCARD_S_SUCCESS) { cardUID = "Error"; } else { cardUID = BitConverter.ToString(receivedUID.Take(4).ToArray()).Replace("-", string.Empty).ToLower(); } return cardUID; } 

对于任何有兴趣的人,我已经写了一步一步的指南来实现这一点。

用于Windows的简单NFC读取系统

请享用!!!