This is a feature of the Cypress driver called port persistence. The terminal application using the COM port can continue accessing the device even if the device is disconnected and reconnected. The COM port is not lost from the device manager if the application has the device opened.
Thanks. How do I detect the device is disconnected in my application? I have a test app that calls SetCommMask(hComm, EV_RXCHAR); then WaitCommEvent(). After the device is disconnected, WaitCommEvent() does not return any error. Using the Windows driver, it will return an error so I know to alert the user or do some other cleanup code.
You may do this by using the "ManagementEventWatcher" class. It subscribes to temporary event notifications based on a specified event query. You can also register a callback function which get triggered when an event happens. EventArrivedEventHandler can be used for the same. Please find the example code snippet below:
string m_deviceRemovalQuery = "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 3";
m_removalEvtWatcher = new ManagementEventWatcher(m_deviceRemovalQuery);
m_removalEvtWatcher.EventArrived += new EventArrivedEventHandler(m_removalEvtWatcher_EventArrived);
void m_removalEvtWatcher_EventArrived(object sender, EventArrivedEventArgs e)