I want to detect when a removal media is inserted or removed from the PC and I have read many threads of how to do it.
Reading other threads and pages gives essential two m开发者_高级运维ethods
- Override WinProc method
- Make SQL query
There is a FileSystemWatcher class, is there reallý not a "DriveSystemWatcher" or something ?
Also, if I try the "SQL" approach it can not compile the program becosue it can not resolve "ManagementEventWatcher", even if I do
using System;
using System.Management;
Help would be appreciated
Regards Stefan.
In order to use classes from System.Management
(so that you can query WMI) you need to add a reference to System.Management.dll
to your project.
The following describes an approach using WMI when you've done this:
Detecting Eject/Insert of Removeable Media
精彩评论