zoukankan      html  css  js  c++  java
  • 获取当前系统可用串口号(转,亲测有效)

    void GetComList_256(CComboBox* pComnum)
    {
      CString strCom, strComOpen;
      int nCom = 0;
      int count = 0;
      HANDLE hCom;
      pComnum->ResetContent();//组合框清空
       do
       {
       nCom++;
         strCom.Format(_T("COM%d"), nCom);
         strComOpen.Format(_T("\\.\COM%d"), nCom);
      hCom = CreateFile(strComOpen, GENERIC_READ | GENERIC_WRITE, 0, NULL,OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);//如果返回不为空则此串口可用
         if (INVALID_HANDLE_VALUE == hCom)
        {
        DWORD error = ::GetLastError();//取得错误信息
        }
         else
        {
        pComnum->AddString(strCom);
        count++;
        }
         CloseHandle(hCom);
      } while (nCom < 256);
     pComnum->SetCurSel(0);
    }

  • 相关阅读:
    子矩阵
    [Ahoi2008]Meet 紧急集合
    立体图
    CF933B A Determined Cleanup
    CF746G New Roads
    树的重量
    CF519E A and B and Lecture Rooms
    矩阵
    深入浅出乘法逆元
    20180519模拟赛T2——pretty
  • 原文地址:https://www.cnblogs.com/judes/p/6005747.html
Copyright © 2011-2022 走看看