gpt4 book ai didi

c# - UsbDevice.FromIdAsync 返回 null

转载 作者:行者123 更新时间:2023-11-30 17:36:31 28 4
gpt4 key购买 nike

我有这个代码:

private async void OnDeviceAdded(DeviceWatcher watcher, DeviceInformation deviceInformation)
{
if (deviceInformation.Name.StartsWith("ClearShot") && deviceInformation.IsEnabled)
{

targetDevice = await UsbDevice.FromIdAsync(deviceInformation.Id);
OnConnected(EventArgs.Empty);

}

}

这实际上是一个从 DeviceWatcher 调用的事件问题是 targetDevice 始终为 null。

没有崩溃没有什么,它只是空的,没有改变。为什么?

编辑:这是我在 list 中的内容:

<DeviceCapability Name="usb">
<Device Id="vidpid:184c 0001">
<Function Type="classId:ff * *"/>
</Device>
</DeviceCapability>

最佳答案

为了内存,我只是注意到它在 UsbDevice.FromIdAsync 之后是空的,应该检查以下内容:

  1. 设备管理器中存在带有 WinUsb 驱动程序的设备。

  2. 在注册表中存在具有生成的 GUID 的多字符串参数 DeviceInterfaceGUIDs

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_184C&PID_0001\8000013\Device Parameters]
    "DeviceInterfaceGUIDs"=hex(7):7b,00,32,00,34,00,42,00,35,00,37,00,46,00,34,00,\
    37,00,2d,00,41,00,37,00,41,00,43,00,2d,00,34,00,46,00,41,00,32,00,2d,00,39,\
    00,43,00,31,00,33,00,2d,00,32,00,38,00,36,00,42,00,30,00,33,00,34,00,46,00,\
  3. Package.appxmanifest 中存在适当的 DeviceCapability

    <Capabilities>
    <DeviceCapability Name="usb">
    <Device Id="vidpid:184C 0001">
    <Function Type="classId:ff * *" />
    <Function Type="name:vendorSpecific" />
    </Device>
    </DeviceCapability>

关于c# - UsbDevice.FromIdAsync 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39427148/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com