c++,Windows 7:识别 USB 拇指驱动器已连接并识别 USB 标识符?

发布于 2024-12-16 14:34:10 字数 199 浏览 3 评论 0原文

我想编写一个软件,当 USB 拇指驱动器连接到 USB 端口时,它会自动将一些文件复制到 USB 拇指驱动器上。为此,我想知道:

  1. 如何编写一个在连接 USB 拇指驱动器时收到通知的 C++ 应用程序?

  2. 有什么方法可以识别 USB 拇指驱动器,以便我可以跟踪是否已插入新的 USB 拇指驱动器?

I'd like to write a software that automatically copies some files onto a usb thumbdrive when it gets connected to the usb port. for this i would like to know:

  1. how can I write a c++ application that gets notified when a usb thumbdrive gets connected?

  2. is there any way to identify the usb thumbdrive, so that i can keep track off whether or not a new usb thumbdrive was inserted already?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小嗷兮 2024-12-23 14:34:10

我认为您可以使用 WM_DEVICECHANGE 窗口消息在系统插入或删除设备时收到通知,这里是进一步阅读的链接 http://msdn.microsoft.com/en-us/library/windows/desktop/aa363480%28v=vs.85%29.aspx

i think you can use the WM_DEVICECHANGE window message to be notified when a device is inserted or removed from the system, here is a link for further reading http://msdn.microsoft.com/en-us/library/windows/desktop/aa363480%28v=vs.85%29.aspx

一袭白衣梦中忆 2024-12-23 14:34:10

Krister's answer covers the basics. What he doesn't metion is how to do (2), idenifying it. You're looking for the DBT_DEVTYP_DEVICEINTERFACE arrival event. This event contains a dbcc_name, which is identifies the exact device. (Provided that the device adheres to the USB specification and has a unique serial number; don't expect cheap Chinese devices to.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文