I have some code which is reading via COM ports. I wanted to make sure that the reader is restarts when a cable is connects/disconnects but unfortunately when I use SerialPort.GetPortNames()
in a timer I always get back the same values it does not matter if I disconnect one or not.
Are there any other options? Do you know why it does not updates?
Thank you in advanced
Edit From the commented link I created that class:
[DllImport("user32.dll", SetLastError = true)]
class CheckSerialPort
{
public static extern IntPtr RegisterDeviceNotification(
IntPtr hRecipient,
IntPtr NotificationFilter,
uint Flags);
}
Do you have any idea how can I sue that to check if anything connected/disconnected? I am reading the forums, but I do not really get it. Might be just because of the long day:P