Detailed description of HID device (USB)
I connected my barcode scanner to a USB port. I needed to change the mode from HID keyboard to serial port emulation (the reader is know seen by the system as regular HID device and not a HID system keyboard) to get data from scanner directly into my app. So far it's all working great.
The problem is that I need to know the VID and PID numbers to find my device. I know these values but I want to find my device by name.
I found a program called SimpleHIDWrite:
http://www.lvr.com/hidpage.htm
When I launch the program my device has a nice description "Symbol Bar Code Scanner".
I tried to reach this name by my self - I used structures:
HIDD_ATTRIBUTES HIDP_CAPS SP_DEVICE_INTERFACE_DATA SP_DEVICE_INTERFACE_DETAIL_DATA SP_DEVINFO_DATA
However I couldn't find a field in structure that allows me to gain access to this description.
Unfortun开发者_运维知识库ately I can't find SimpleHIDWrite source code to learn how to do this.
Can you help me?
In the same section of that page, there is a HidTest program with source. That program apparently uses HID controller code found through a link called "HID Controller component suite for Delphi". Perhaps that could give you what you're looking for? (At least if you can pick the relevant pieces out of all that Delphi code.)
I have been researching the exact kind of thing recently, but I haven't had the time to actually try any of it yet. So what follows here is a bit speculative.
I believe what you need to do is open connection to the device as USB device. Functions at the HID level don't appear to give the description you want. Here is a different SO question about getting the VendorID and ProductID from a USB device. I think you could use a very similar technique to read the USB_DEVICE_DESCRIPTOR
and thus get access to the iProduct
field, which I believe should be the description you want.
I have come across a program called USBView that apparently does this kind of communication (among other things) with USB devices. I found a compiled version of it here. However the source is supposedly included in the Windows Driver Development Kit. That would likely be C or C++ source, but I have not yet had time to download the DDK from Microsoft and confirm what's actually there.
EDIT:
I've had time to dig into this deeper. And what you found out about HidD_GetProductString
was helpful too. I've also found this page of examples from Intel. The "Display HID" program there shows one way to use that function.
Based on that function's documentation and that example, I get the impression that it is reading the same iProduct
from the device, apparently doing so from the HID level instead of the USB level. Or something like that. All I know for sure is that it is working in my own test program so far.
I found the answer to my question here on the lvr.com
forums:
Detailed description of HID device (USB) (lvr.com/forums)
Hmm...the problem with iProduct is that first I have to send request for this Strings describing device to the device and then recive data. Bar code scanners are read only so I can't send data (request) to device.
I discovered that in SimpleHID there is a description of my scanner "Symbol bar ocde scanner" and it's exactly the same name that I see i control panel (devices and printers). So my question is how to get this name of device?
精彩评论