我有一个使用Hid.Net库的控制台应用程序(.Net Core)项目,最终目标是连接我的 HID 游戏控制器并从中读取数据,但作为理解库的起点,我有编写代码来枚举我想连接的游戏控制器的连接设备。我编写的代码遵循库中的文档。但是当我运行这个项目时,我得到了错误:
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());
}
}
}
}
我不明白我做错了什么,因此非常感谢任何解释或见解。
尚方宝剑之说
相关分类