I'm using TJvHidDeviceController class to retrive HID Device information. I have plugged two HID devices, but i'm trying to ge the "DevicePath" of SP_DEVICE_INTERFACE_DETAIL_DATA_A structure always getting the device path as '\'. So Ican't open CreateFile function. Please help me to solve this issue. My OS win7. Thanks All.
This is guessing!
The one thing I can think of is:
TJvHidDeviceController calls a Windows API call WITHOUT using an A or W suffix. The structure used is SP_DEVICE_INTERFACE_DETAIL_DATA_A, the ANSI version. Now, if you use Delphi 2009 or higher, the routine will expect SP_DEVICE_INTERFACE_DETAIL_DATA_W. size is the same so everything looks OK. But the strings stored will be USC2 encoded (WideChars) instead of ANSI encoded -> thus after every ANSI character there will be a null byte. TJvHidDeviceController probably converts the character array back to a pascal string using a function like StrPas and hence, you only see the first character.
Check: Set a breakpoint just after the function call that fills the structure and use the CPU window to view the content as a memory dump. If you see ANSI characters every other byte and null bytes in between, you can confirm that the above scenario is the case.
Solution: