如何检测 CD/DVD/USB 何时插入或移除并获取驱动器盘符?
我想检测何时插入或移除磁盘(CD / DVD)或 USB。
我知道我应该使用 WM_DEVICECHANGE
消息,但我的问题是获取驱动器的卷(字母),我尝试通过 WMI 查询
和 获取它Win32_VolumeChangeEvent 也是如此,但我不能!
有一个示例并且工作正常,我如何通过Delphi做到这一点?
I want to detect when a Disk ( CD / DVD ) or an USB inserted or removed.
I know that I should work with WM_DEVICECHANGE
message , but my problem is getting the Volume ( Letter ) of the Drive , I tried to Get it by WMI Query
and Win32_VolumeChangeEvent
too but I could not!
there is an Example and work fine , how can I do this by Delphi?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检测媒体插入或移除 (MSDN)
检测硬件插入和/或移除 (codeproject.com)
// 编辑:
...在取出或插入 CD 时收到通知? ( Torry 的 Delphi 页面)
以及
http://www.google.com/search?q= Delphi+WMDeviceChange
Detecting Media Insertion or Removal (MSDN)
Detecting Hardware Insertion and/or Removal (codeproject.com)
// EDIT:
...get notified when a CD is removed or inserted? (Torry's Delphi Page)
and also
http://www.google.com/search?q=Delphi+WMDeviceChange
对于 CD 插入,您需要 CDEvents: http://www.torry.net/ vcl/filedrv/cd/dtcdevents.zip
工作精美。如果您需要示例代码,请给我发送电子邮件([电子邮件受保护])。
For CD insertions, you want CDEvents: http://www.torry.net/vcl/filedrv/cd/dtcdevents.zip
Works beautifully. E-mail me ([email protected]) if you want sample code.