简体   繁体   English

在Windows服务中捕获“外部驱动器插入”事件

[英]Catching 'external drive inserted' event in a windows service

I'm trying to write a super-simple podcast-to-device downloading service to use for running. 我正在尝试编写一个超级简单的播客到设备下载服务来运行。 I imagine that it'll like this: 我想它会是这样的:

Whenever a particular device is plugged in (via USB), it: 每当插入特定设备(通过USB)时,它:

  • Deletes everything from the device 从设备中删除所有内容
  • Checks for all the latest entries in a number of RSS Podcast feeds 检查许多RSS Podcast源中的所有最新条目
  • Downloads those to the device 将这些内容下载到设备
  • Notifies the user about when its done. 通知用户何时完成。

I have some passing experience with windows services, but am not sure how to (using .NET/C#) catch the 'media device/usb hard drive has been plugged in' event. 我有一些Windows服务的传递经验,但我不知道如何(使用.NET / C#)捕获'媒体设备/ usb硬盘插入'事件。 Any advice? 有什么建议?

The simplest solution would be to periodically enumerate the devices! 最简单的解决方案是定期枚举设备!

CodeProject has a comprehensive C# article for this here : http://www.codeproject.com/KB/system/DriveDetector.aspx CodeProject有一篇全面的C#文章: http//www.codeproject.com/KB/system/DriveDetector.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM