我有阅读器:Promag PCR-300FMU,USB(无手册,无 SDK)。
所以我照顾了winscard.dll上的文档
public List<string> ListReaders()
{
int ReaderCount = 0;
List<string> AvailableReaderList = new List<string>();
//Make sure a context has been established before
//retrieving the list of smartcard readers.
retCode = Card.SCardListReaders(hContext, null, null, ref ReaderCount);
if (retCode != Card.SCARD_S_SUCCESS)
{
MessageBox.Show(Card.GetScardErrMsg(retCode));
//connActive = false;
}
byte[] ReadersList = new byte[ReaderCount];
//Get the list of reader present again but this time add sReaderGroup, retData as 2rd & 3rd parameter respectively.
retCode = Card.SCardListReaders(hContext, null, ReadersList, ref ReaderCount);
if (retCode != Card.SCARD_S_SUCCESS)
{
MessageBox.Show(Card.GetScardErrMsg(retCode));
}
string rName = "";
int indx = 0;
if (ReaderCount > 0)
{
// Convert reader buffer to string
while (ReadersList[indx] != 0)
{
while (ReadersList[indx] != 0)
{
rName = rName + (char)ReadersList[indx];
indx = indx + 1;
}
//Add reader name to list
AvailableReaderList.Add(rName);
rName = "";
indx = indx + 1;
}
}
return AvailableReaderList;
}
this.ListReaders() 发回给我 ==> 一件 ==> 通用 EMV 智能卡读卡器 0 ==> 这不是我的读卡器
这是我得到的 VID 和 PID
USB\VID_1667&PID_0005&MI_01\6&DE89751&0&0001 VID: 1667 PID: 0005 USB\VID_1667&PID_0005&MI_00\6&DE89751&0&0000 VID: 1667 PID: 0005 USB\VID_1667&PID:48_0005\PGM-T
public static UsbDevice MyUsbDevice1;
public static UsbDeviceFinder MyUsbFinder1 = new UsbDeviceFinder(1667, 0005);
public static UsbDevice MyUsbDevice2;
public static UsbDeviceFinder MyUsbFinder2 = new UsbDeviceFinder(Int32.Parse("1667", System.Globalization.NumberStyles.HexNumber), Int32.Parse("0005", System.Globalization.NumberStyles.HexNumber));
static void Main(string[] args)
{
//GetAllVidAndPidOnPC();
MyUsbDevice1 = UsbDevice.OpenUsbDevice(MyUsbFinder1);
MyUsbDevice2 = UsbDevice.OpenUsbDevice(MyUsbFinder2);
}
在 MyUsbDevice1 和 MyUsbDevice2 中始终为 NULL
你能帮助我吗 ?