| Shannon Walker 2005-12-22, 7:36 am |
| I have a Delphi application that is using Async Pro components to handle the serial communications. Now if a user doesn't have a serial port on their PC, they can use a USB to serial adapter to connect to their device in order to communicate with it using our software.
The problem comes in when a user removes the USB to serial cable from the PC during an active communication session. I am getting access violations when this occurs. Now I read about trapping the WM_DEVICECHANGE message and checking if the DBT_DEVICEREMOVECOMPLETE message was received. This seems to work OK, but what if they have another USB device connected while using our software and remove that one? This would trigger this message too. I really only want to handle when the USB to serial adapter being used during the communication session is removed. Is there a way to do this, and if so is there any examples of how this might have been done that I could follow?
Any help on this would be greatly appreciated. |