1

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?

asked Oct 3, 2016 at 16:12

1 Answer 1

1

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.

answered Oct 7, 2016 at 2:51
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately, you are not allowed to use extern's in a UWP app :/
@soren.bendtsen, why not? I have verified it passes the windows store certification.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.