TJvHidDeviceController“DevicePath”总是显示“\”
我正在使用 TJvHidDeviceController 类来检索 HID 设备信息。我已经插入了两个 HID 设备,但我试图获取 SP_DEVICE_INTERFACE_DETAIL_DATA_A 结构的“DevicePath”,但设备路径始终为“\”。所以我无法打开CreateFile函数。请帮我解决这个问题。我的操作系统win7。 谢谢大家。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是猜测!
我能想到的一件事是:
TJvHidDeviceController 调用 Windows API 调用而不使用 A 或 W 后缀。使用的结构是 SP_DEVICE_INTERFACE_DETAIL_DATA_A,ANSI 版本。现在,如果您使用 Delphi 2009 或更高版本,则例程将需要 SP_DEVICE_INTERFACE_DETAIL_DATA_W。尺寸相同,所以一切看起来都不错。但存储的字符串将采用 USC2 编码(WideChars)而不是 ANSI 编码 ->因此,每个 ANSI 字符后面都会有一个空字节。 TJvHidDeviceController 可能使用 StrPas 之类的函数将字符数组转换回 pascal 字符串,因此,您只能看到第一个字符。
查看:
在填充结构的函数调用之后设置一个断点,并使用 CPU 窗口以内存转储的形式查看内容。如果您每隔一个字节看到 ANSI 字符,并且在中间看到空字节,则可以确认上述情况就是这种情况。
解决方案:
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: