USB thumb drives USB harddisks USB DVD writer USB Bluetooth devices USB headsets usb mouse USB keyboard USB webcams / cameras
WqlEventQuery q_creation = new WqlEventQuery(); private void Form2_Load(object sender, EventArgs e) { q_creation.EventClassName = "__InstanceCreationEvent"; q_creation.WithinInterval = new TimeSpan(0, 0, 2); //How often do you want to check it? 2Sec. q_creation.Condition = @"TargetInstance ISA 'Win32_DiskDriveToDiskPartition'"; var mwe_creation = new ManagementEventWatcher(q_creation); mwe_creation.EventArrived += new EventArrivedEventHandler(USBEventArrived_Creation); mwe_creation.Start(); // Start listen for events } /// <summary> /// Callback event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void USBEventArrived_Creation(object sender, EventArrivedEventArgs e) { MessageBox.Show("Device Connected"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)