如何检测USB设备何时连接/断开?
我对使用 Delphi 使用 USB 设备感到不舒服,并且对编写设备驱动程序的细节几乎一无所知(尽管我在学习使用 GoASM 进行汇编时遇到过一些)。
该设备可以是 USB 调制解调器或 USB 打印机。
我需要的是一个方向和解决该主题的示例代码。
I don't feel comfortable harnessing USB device with Delphi and have a next to nothing knowledge of the details of writing device driver (though I've come accross some when learning assembly with GoASM).
The device could be either an usb modem or an usb printer.
What I need is a direction to go and sample code adressing the topic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是取自 检测 USB 设备是否已连接
This was taken from detect if usb device is connected
您可以使用一些shell 脚本来执行此操作。
当设备连接时,命令 lsusb 显示此信息,并在设备断开连接后从列表中删除。
因此,在 shell 脚本中,您需要找到旧列表和当前列表之间的差异。
最后,您需要将此脚本作为 cron 作业 运行,它会定期检查。
问候,
巴伦·帕里查
You can use some shell script to do so.
when device is connected command lsusb shows this and removes from list after the device gets disconnected.
So in your shell script you need to find the difference between old list and current list.
Finally you need to run this script as a cron job, which checks in frequent interval.
Regards,
Barun Parichha