MFC 扫描COM端口程序

简介:

                                             MFC 扫描COM端口程序

 

 

 

 

MFC 扫描COM端口程序源代码MFC 扫描COM端口程序源代码

 

主要功能简介:

 

核心函数就是Scan。不仅可以扫描出实际的蓝牙,打印机等COM端口,而且还可以扫描出虚拟机来的COM端口。

不仅可以显示名称,还可以显示生产厂商的具体参数

 

 

/* func name: Scan description: Scan and display the COM port information This is the main function of the app. It detect your port, as well as the virtual port. */ HRESULT CSmartScanerDlg::Scan(void) { HDEVINFO hDevInfo; SP_DEVINFO_DATA DeviceInfoData; DWORD i; // Create a HDEVINFO with all present devices. hDevInfo = SetupDiGetClassDevs((LPGUID)&GUID_DEVCLASS_PORTS, 0, // Enumerator 0, DIGCF_PRESENT); if (hDevInfo == INVALID_HANDLE_VALUE) { // Insert error handling here. return 1; } // Enumerate through all devices in Set. DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i, &DeviceInfoData);i++) { DWORD DataT; LPTSTR buffer = NULL; DWORD buffersize = 0; // // Call function with null to begin with, // then use the returned buffer size // to Alloc the buffer. Keep calling until // success or an unknown failure. // while (!SetupDiGetDeviceRegistryProperty( hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, &DataT, (PBYTE)buffer, buffersize, &buffersize)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Change the buffer size. if (buffer) LocalFree(buffer); buffer = (LPTSTR)LocalAlloc(LPTR,buffersize); } else { // Insert error handling here. break; } } //printf("Result:[%s]/n",buffer); /** disp is MFC Edit Control CString variable. here, I just use it display the scan results. the buffer just contains the result. and if you want to get other information ,just change SPDRP_FRIENDLYNAME(please look up in MSDN) */ disp.Append(buffer); disp.Append(_T("/r/n")); conEdit.SetWindowTextW(disp.GetString()); } SetupDiDestroyDeviceInfoList(hDevInfo); if (!wcscmp(disp.GetString(), _T("/r/n"))){ MessageBox(_T("no device find"), _T("prompt")); } return S_OK; }

 

 

MFC 扫描COM端口程序源代码MFC 扫描COM端口程序源代码

目录
相关文章
|
8天前
扫描端口nc
扫描端口nc
9 0
|
8天前
|
网络协议
第二轮学习笔记: 扫描工具 -- nmap端口扫描
第二轮学习笔记: 扫描工具 -- nmap端口扫描
28 0
|
5月前
|
Java 应用服务中间件 Linux
linux安装jdk1.8 +nginx +springboot 实现通过nginx80转发8888端口访问springboot程序
linux安装jdk1.8 +nginx +springboot 实现通过nginx80转发8888端口访问springboot程序
109 0
|
5月前
|
XML 网络协议 安全
主动扫描-Nmap-端口、系统、服务扫描
主动扫描-Nmap-端口、系统、服务扫描
130 0
|
6月前
|
网络协议 前端开发 Java
windows系统下重启springboot项目时,提示端口被占用,却找不到占用端口的程序
windows系统下重启springboot项目时,提示端口被占用,却找不到占用端口的程序
|
6月前
|
Python
python 扫描局域网主机、爆破端口
python 扫描局域网主机、爆破端口
51 0
|
7月前
|
开发框架 .NET Windows
windows 本地443端口被占用,ASP.NET Core程序拒绝访问
windows 本地443端口被占用,ASP.NET Core程序拒绝访问背景:本地的ASP.NET Core程序在配置了HTTPS并且监听443端口,通过https访问被拒绝,提示没有权限,输入swagger路径访问swagger也提示未找到相关页面。解决:一般情况下,访问我们的ASP.NET Core 程序的swagger页面并不需要什么权限,而且本地调试运行swagger文档也没有什...
61 1
|
9月前
|
Python
【从零学习python 】74. UDP网络程序:端口问题与绑定信息详解
【从零学习python 】74. UDP网络程序:端口问题与绑定信息详解
129 0
|
11月前
|
安全 网络协议 NoSQL
对内网服务端口进行扫描
对内网服务端口进行扫描,根据开放的端口服务选择横向的方法。
294 1
|
11月前
|
数据库
19c初始化数据库提示端口1521占用,但查不到占用的程序[DBT-06103]
19c初始化数据库的时候,提示端口占用,但查不到占用的程序。这个问题很诡异,如果按照提示的思路去查,找占用端口的进程,就走入了错误的方向。