public void Check() { var devices = loader.GetDevices(vid, pid); signerCount = devices.Count(); if (devices.Count() == 0)//直接移除设备 { atcdevice = null; stream = null; return; } if (atcdevice == null)//打开设备 { atcdevice = devices.First(); stream = atcdevice.Open(); return; } bool bFind = false; foreach (var d in devices) { if (d.DevicePath == atcdevice.DevicePath) {//same bFind = true; } } //找不到设备了 if (!bFind) { atcdevice = null; stream = null; } }
public static int CheckDevice() { var devices = loader.GetDevices(0x0483, 0x572b); var signerCount = devices.Count(); if (devices.Count() == 0)//直接移除设备 { atcdevice = null; stream = null; return(0); } if (atcdevice == null)//打开设备 { atcdevice = devices.First(); stream = atcdevice.Open(); return(signerCount); } bool bFind = false; foreach (var d in devices) { if (d.DevicePath == atcdevice.DevicePath) {//same bFind = true; } } //找不到设备了 if (!bFind) { atcdevice = null; stream = null; } return(signerCount); }