c# - How do I get the Vendor and Product strings in case of a HID device on Windows? -


i need information idproduct , idvendor of plugged in hid device on windows machine. how usb_device_descriptor given hid device?

i searched internet, found examples of devices being queried using winusb library , getting usb_device_descriptor. understanding cannot use winusb plugged in hid device.

what need use hid device then?

if you're using hidlibrary, can device this:

_device = hiddevices.enumerate(vendorid, productid, usagepage).firstordefault();  if (_device != null) {     _device.opendevice();     string product = getproductstring(_device);     string mfg = getmanufacturerstring(_device); } 

with latter 2 functions defined this:

    private string getproductstring(hiddevice d) {         byte[] bs;         _device.readproduct(out bs);         string ps = "";         foreach (byte b in bs) {             if (b > 0)                 ps += ((char)b).tostring();         }         return ps;     }      private string getmanufacturerstring(hiddevice d) {         byte[] bs;         _device.readmanufacturer(out bs);         string ps = "";         foreach (byte b in bs) {             if (b > 0)                 ps += ((char)b).tostring();         }         return ps;     } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -