TVaComm OnErrorException Handling

I have the situation where the USB connected com port could have been disconnected before the call to the WriteText method. When this occurs, I get an exception.

So, I've attached an exception handler to OnErrorException, which at least allows me to log the error and hopefully take some action. I've found though that the exception keeps getting raised in a loop.

What action do I need to perform on TVaComm to clear the exception and disable it so the active property becomes false?

No simple answer to this one?

Hi, for the USB virtual COM ports, that can "disappear" on cable disconnect, I detect the windows message WM_DEVICECHANGE.

procedure USBchangeHandler(var myMsg: TMessage); message WM_DEVICECHANGE;

Within this event I can detect Device Arrival or Remove, and in such case close the COM port.

Regards

I already use WM_DEVICECHANGE but that doesn't help when the disconnection occurs mid transmission.