【发布时间】:2019-01-05 20:31:21
【问题描述】:
我有一个使用 Hid.Net 库的控制台应用程序 (.Net Core) 项目,其最终目标是连接我的 HID 游戏控制器并从中读取数据,但作为了解库的起点,我编写了代码来枚举我想连接的游戏控制器的连接设备。我编写的代码遵循库中的documentation。但是当我运行项目时,我得到了错误:
System.Exception:无法获取设备接口详细信息。错误代码:122
这是我写的代码:
using System;
using System.Threading.Tasks;
using Device.Net;
using Hid.Net.Windows;
using Usb.Net.Windows;
namespace IOLibrary
{
class Program
{
static void Main(string[] args)
{
CheckforDevices();
Console.ReadLine();
}
static async Task CheckforDevices()
{
try
{
WindowsHidDeviceFactory.Register();
WindowsUsbDeviceFactory.Register();
var devices = await DeviceManager.Current.GetConnectedDeviceDefinitions(0x0079, 0x0006);
foreach(var device in devices)
{
Console.WriteLine(device.DeviceId);
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
我不明白我做错了什么,因此非常感谢任何解释或见解。
【问题讨论】: