/// <summary> /// Set up the hidden form. /// </summary> /// <param name="detector">DriveDetector object which will receive notification about USB drives, see WndProc</param> public DetectorForm(DriveDetector detector) { mDetector = detector; this.MinimizeBox = false; this.MaximizeBox = false; this.ShowInTaskbar = false; this.ShowIcon = false; this.FormBorderStyle = FormBorderStyle.None; this.Load += new System.EventHandler(this.Load_Form); this.Activated += new EventHandler(this.Form_Activated); }
protected override void OnStart(string[] args) { //ManagementEventWatcher watcher = new ManagementEventWatcher(); //WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2"); //watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); //watcher.Query = query; //watcher.Start(); //watcher.WaitForNextEvent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); }