public void UpdateDeviceList() { KSJApiBase.KSJ_UnInit(); KSJApiBase.KSJ_Init(); ComboBox_DEVICE_LIST.Items.Clear(); m_nDeviceNum = KSJApiBase.KSJ_DeviceGetCount(); Label__DEVICENUM.Text = String.Format("{0} Device Found:", m_nDeviceNum); if (m_nDeviceNum == 0) { m_nDeviceCurSel = -1; return; } if (m_nDeviceCurSel >= m_nDeviceNum) { m_nDeviceCurSel = 0; } for (int i = 0; i < m_nDeviceNum; i++) { m_DeviceInfo[i].nIndex = i; KSJApiBase.KSJ_DeviceGetInformationEx(i, ref m_DeviceInfo[i].DeviceType, ref m_DeviceInfo[i].nSerials, ref m_DeviceInfo[i].wFirmwareVersion, ref m_DeviceInfo[i].wFpgaVersion); byte btMajVersion = (byte)((m_DeviceInfo[i].wFirmwareVersion & 0xFF00) >> 8); // 得到主版本号 byte btMinVersion = (byte)(m_DeviceInfo[i].wFirmwareVersion & 0x00FF); // 得到副版本号 byte btFpgaMajVersion = (byte)((m_DeviceInfo[i].wFpgaVersion & 0xFF00) >> 8); // 得到主版本号 byte btFpgaMinVersion = (byte)(m_DeviceInfo[i].wFpgaVersion & 0x00FF); // 得到副版本号 string szText = String.Format("Index({0})-Type({1})-Serials({2})-FwVer({3}.{4})-FpgaVer({5}.{6})", i, KSJGS.g_szDeviceType[(int)(m_DeviceInfo[i].DeviceType)], m_DeviceInfo[i].nSerials, btMajVersion, btMinVersion, btFpgaMajVersion, btFpgaMinVersion); ComboBox_DEVICE_LIST.Items.Insert(i, szText); } }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { try { KSJApiBase.KSJ_PreviewStart(0, false); KSJApiBase.KSJ_UnInit(); } catch (Exception ex) { MessageBox.Show(ex.Message); } Application.Exit(); }