(转)VC得到可用的串口列表
2017-06-13 15:40
357 查看
//枚举串口 //参数:bEnablePort,哪个串口有效,bEnablePort[0]表示COM1,bEnablePort[n-1]表示COMn //返回值:有效的串口个数 int EnumAllComPort(bool* bEnablePort) { int nCommSum = 0;//串口个数 HANDLE hCom; CString str; for(int i=1;i<=256;i++) { str.Format(_T("COM%d"),i); hCom = CreateFile(str, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (hCom == INVALID_HANDLE_VALUE) { bEnablePort[i-1] = false; continue; } else { bEnablePort[i-1] = true; } CloseHandle(hCom); nCommSum++; } return nCommSum; }
原文地址:http://blog.csdn.net/hanjiangying/article/details/5490854
相关文章推荐
- VC得到可用的串口列表
- VC++获取计算机可用串口并放入ComboBox控件中
- VC++得到当前可用物理内存大小
- VC 搜索本地可用串口
- VB得到网絡中可用的SQL服務器列表
- VC编程通过访问注册表得到串口数量
- VC枚举电脑上可用串口
- 获取系统可用串口列表
- VC++ 枚举串口列表
- 用API得到局域网中可用SqlServer服务器列表
- VC++ 的串口通讯
- 用Qt获取系统可用的串口信息
- C#获取串口列表
- VC常用数据类型列表
- 深入浅出VC++串口编程之基于Win32 API
- VC中ODBC数据库技术应用源程序详解之一(串口数据保存相关)
- VC++ 的串口通讯(3)
- 得到指定字符串列表中,指定个数的字符串
- linux设备驱动,tty串口编程 如何查看linux下串口是否可用?串口名称等
- 基于VC++的串口编程