当我运行它时, allDevices 列表是空的。我开始了一个新的 VB.NET 控制台项目,并安装了 Nuget LibUsbDotNet。我的代码是这样的:Imports SystemImports LibUsbDotNetImports LibUsbDotNet.InfoImports LibUsbDotNet.MainImports System.Collections.ObjectModelModule Module1 Public MyUsbDevice As UsbDevice Public Sub Main(args As String()) ' Dump all devices and descriptor information to console output. Dim allDevices As UsbRegDeviceList = UsbDevice.AllDevices For Each usbRegistry As UsbRegistry In allDevices If usbRegistry.Open(MyUsbDevice) Then Console.WriteLine(MyUsbDevice.Info.ToString()) For iConfig As Integer = 0 To MyUsbDevice.Configs.Count - 1 Dim configInfo As UsbConfigInfo = MyUsbDevice.Configs(iConfig) Console.WriteLine(configInfo.ToString()) Dim interfaceList As ReadOnlyCollection(Of UsbInterfaceInfo) = configInfo.InterfaceInfoList For iInterface As Integer = 0 To interfaceList.Count - 1 Dim interfaceInfo As UsbInterfaceInfo = interfaceList(iInterface) Console.WriteLine(interfaceInfo.ToString()) Dim endpointList As ReadOnlyCollection(Of UsbEndpointInfo) = interfaceInfo.EndpointInfoList For iEndpoint As Integer = 0 To endpointList.Count - 1 Console.WriteLine(endpointList(iEndpoint).ToString()) Next Next Next End If Next ' Free usb resources. ' This is necessary for libusb-1.0 and Linux compatibility. UsbDevice.[Exit]() ' Wait for user input.. Console.ReadKey() End SubEnd Module我的桌面 USB 设备...
1 回答
一只名叫tom的猫
TA贡献1906条经验 获得超3个赞
我相信我的台式机太旧了,虽然我最近升级到了 Win 10。所以解决问题,我使用了新的 Win 10 笔记本电脑,安装并运行过滤器(子)驱动程序并选择了我的笔记本电脑的网络摄像头(作为测试 VID&PID),安装了 libUsb-Win32,创建了一个 .NET 控制台项目(我同时使用了 VB 和 C#),做了 VS > proj > Refs > NUGET > 浏览了 LibUsbDotNet,安装了它,粘贴了 Sourceforge 的 libUsbDotNet 中的第一个示例,并且它起作用了很棒:它连接到网络摄像头驱动程序(由过滤器子驱动程序选择),并读取正确的 VID&PID。(示例报告错误,因为网络摄像头驱动程序没有响应轮询,但这是意料之中的)。
- 1 回答
- 0 关注
- 306 浏览
添加回答
举报
0/150
提交
取消