Reputation: 435
I have a HIDDevice in a Universal Windows Platform application, that I would like to read the USB Descriptors of.
This is information like manufacturer, serial number etc.
The HidDevice does not seem to support this. I looks like the UsbDevice class does, but it does not allow to be created from a HID class device.
https://msdn.microsoft.com/en-us/library/windows/hardware/dn303351(v=vs.85).aspx
I tried to create a UsbDevice from a HidDevice id, but that fails.
Anyone tried this before?
Upvotes: 1
Views: 695
Reputation: 2030
I'm not sure if this is a 100% accurate answer, because I haven't tested it yet.
But a quick thought on this is to use platform interop.
So we can use the below API to get the HID serial number, see to https://msdn.microsoft.com/en-us/library/windows/hardware/ff539683(v=vs.85).aspx
Once you have it declared in your C# code, you can p-invoke it.
[DllImport("hid.dll", SetLastError = true)]
static extern bool HidD_GetSerialNumberString(IntPtr HidDeviceObject, ref byte Buffer, Int32 BufferLength);
There's a nice open-source HidLibrary for your reference. https://github.com/mikeobrien/HidLibrary
Let me know if it helps.
Upvotes: 1