VS2017 C# .net 3.5 平台搭建 demo 中是个的建议串口助手,功能完善中。
基于QT 5做的usb插拔检测,我主用是用于检测usbkey的(通过 VID,PID),其他设备应该也是可以的,测试过u盘,usb转串口线,usb key都能识别,
这是一个用于自动识别usb插拔,并且自动取得其相应硬件属性的mfc小程序。项目打包发的。
USB Device(VID_1f3a_PID_efe8) 感叹号
该项目采用wmi技术开发,界面采用WPF技术
USB Device(VID_1f3a_PID_efe8)
MFC监控USB接口插拔情况,并获取VID与PID显示出来。 开发工具:VS2015
类似于windows系统自带的检测插拔的提示,本程序通过一个命令行程序显示USB接口的硬件插拔情况。亲测可成功运行。
此代码是遍历pc上usb设备。 包含控制器 hub port 设配id 等信息 usb其实和串口是一样的,其端口也是固定的(如果你不接扩展hub)。 有时一台电脑接多个相同的usb设备,如果接连个摄像头(前后各一个),我们如果区分打开的是哪一个呢? 1、先把usb设备先遍历出来,得到usb信息(设备串等)。 2、通过打开usb设备时返回信息(这个很重要 //usb#vid_1d27&pid;_0600#5&10ef021e;&0&5#{c3b5f022-5a42-1980-1909-ea72095601b1})。 3、遍历注册表得到usb设备信息(#define USB_REGPATH "SYSTEM\\CurrentControlSet\\Enum\\USB\\" )。 4、通过第1条的设备串、第2条打开设备返回信息、注册表。就可以确定usb设备(控制器->hub->端口) read by jerry
易语言源码易语言USB设备控制源码.rar
文件夹中包含hidapi.h hidapi.dll hidapi.lib,我是在windows10系统中用VS2013编译的release版本,我用于qt的调用,是可以实现的。 调用过程: int res; res = hid_init(); wchar_t wstr[MAX_STR]; int i; // Open the device using the VID, PID, // and optionally the Serial number. handle = hid_open(0x0483, 0x5750, NULL); if(handle == NULL) { qDebug() << "NULL-----------------------NULL" ; return; } else { qDebug() << " not ------------NULL-----------------------NULL" ; } // Read the Manufacturer String res = hid_get_manufacturer_string(handle, wstr, MAX_STR); wprintf(L"Manufacturer String: %s\n", wstr); // Read the Product String res = hid_get_product_string(handle, wstr, MAX_STR); wprintf(L"Product String: %s\n", wstr); // Read the Serial Number String res = hid_get_serial_number_string(handle, wstr, MAX_STR); wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr); // Read Indexed String 1 res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); wprintf(L"Indexed String 1: %s\n", wstr); qDebug("hid read start"); int res = hid_set_nonblocking(handle, 0); while (1) { res = hid_read(handle,buf,sizeof(buf)); QString asd ; for(int i = 0;i < sizeof(buf);i++) { char str[20]; sprintf(str , "%02x",buf[i]); asd+=str ; } if(!cardInfo.contains(asd.toUpper())) { cardInfo.append(asd.toUpper() ); for(int i = 0;i < cardInfo.size() ;i++) { dealWithData( cardInfo[i]); } } }
硬件ID:VID_5372%26PID_2303 usb 转串口驱动
获取插入的USB得PID跟VID,可以根据PID跟VID确定智能机的型号,然后安装对应的驱动。
一获取USB信息的库,有源码,和一个测试程序
使用C++开发的,用于获取插入USB的VID和PID。
to detect usb device in windows and get vid pid
usb device(vid_1f3a_pid_efe8) usb device(vid_1f3a_pid_efe8) usb device(vid_1f3a_pid_efe8)
USB的驱动(vid—1f3a—pid—efe8)驱动
//调用方法:搜索所有USB设备.. USB.WhoUsbDevice(0, 0, Guid.Empty); //调用方法:搜索所有USB设备.. USB.WhoUsbDevice(0, 0, Guid.Empty);