C#, WPF, Windows 7, PC, Visaul Studio 2010
I try to trap when the user attach a COM port to the PC by doing this
            myCOMAddEventQue = new WqlEventQuery("__InstanceCreationEvent", "TargetInstance ISA 'Win32_SerialPort'");
            myCOMAddEventQue.WithinInterval = TimeSpan.FromSeconds(1);
            myCOMAddWatcher = new ManagementEventWatcher(myCOMAddEventQue);
            myCOMAddWatcher.EventArrived += new EventArrivedEventHandler(COMAddEvent);
            myCOMAddWatcher.Start();
But this generates the error "ObjectDisposedException was unhandled" ??
I am able to trap USB memorysticks by
            myDiscA开发者_如何转开发ddlEventQue = new WqlEventQuery("__InstanceCreationEvent", "TargetInstance ISA 'Win32_LogicalDisk' and (TargetInstance.DriveType = 2 or TargetInstance.DriveType = 4)");
Why are Windows generating the error for the COM port?
Regards Stefan
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论