BOOL CConfigurationDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // create available device list. SetControlWinText(0); SetControlText(3202, 2) ; InstantDiCtrl * instantDiCtrl = AdxInstantDiCtrlCreate(); ICollection<DeviceTreeNode>* sptedDevices = instantDiCtrl->getSupportedDevices(); if (sptedDevices->getCount() == 0) { GetDlgItem(IDOK)->EnableWindow(FALSE); GetDlgItem(IDCANCEL)->EnableWindow(FALSE); AfxMessageBox(_T("No device to support the currently demonstrated function!")); return FALSE; }else{ for (int i = 0; i < sptedDevices->getCount(); ++i) { DeviceTreeNode const & node = sptedDevices->getItem(i); TRACE("%d, %s\n", node.DeviceNumber, node.Description); TCHAR des[MAX_DEVICE_DESC_LEN]; m_comboBox_Device.AddString(WCHAR_TO_TCHAR(node.Description,des)); m_comboBox_Device.SetItemData(i,node.DeviceNumber); } sptedDevices->Dispose(); } instantDiCtrl->Dispose(); m_comboBox_Device.SetCurSel(0); return TRUE; }
void ReadHardware::init() { // select a device by device number or device description and specify the access mode. DeviceInformation devInfo(deviceDescription); ret = instantDiCtrl->setSelectedDevice(devInfo); if( ret != Success) { throw LzException(1, "initialize hardware failed"); } // 设置该端口为输入模式 ICollection<PortDirection>* portDirection = instantDiCtrl->getPortDirection(); portDirection->getItem(m_nPortNum).setDirection(Input); }