Libusb
libusb_github
建议直接下载库,编译好麻烦
QT调用
.pro文件添加:
win32: LIBS += -L$$PWD/LIB/libusb/x64/ -llibusb-1.0
.cpp调用即可
#include "LIB/libusb/libusb.h"
void class_name::fun(){/* 1. */libusb_init(NULL);/**/struct libusb_device **device_list;int num_devices = libusb_get_device_list(NULL, &device_list);/**/for (int i = 0; i < num_devices; i++){struct libusb_device *dev = device_list[i];struct libusb_device_descriptor dev_desc;libusb_get_device_descriptor(dev, &dev_desc);int id_vendor = dev_desc.idVendor;int id_product = dev_desc.idProduct;qDebug() << "id_vendor="<<id_vendor;qDebug() << "id_product="<<id_product;/**/struct libusb_device_handle *dev_handle = NULL;libusb_open(dev, &dev_handle); //ordev_handle = libusb_open_device_with_vid_pid(NULL, 0x0525, 0xa4a0);}
}