1

I would like to write a small windows application, which list all the connected serial ports, gets the status of the pins and can disable and enable the DTR and RTS output lines.

Can someone give me an example how to do it in C++ or C#?

tomas
  • 67
  • 1
  • 9
  • Are you sure you still *have* any serial ports? – Bo Persson Dec 06 '17 at 13:50
  • I saw the other serial port question (https://stackoverflow.com/questions/18539104/controlling-dtr-and-rts-pin-of-serial-port-in-c-on-windows-platform) but it only answered by controlling it. I don't know what command should I send to the port to Enable or Disable it. Please delete the duplication flag from my question. – tomas Dec 06 '17 at 13:53
  • This is not in general possible, the winapi does not permit calling GetCommState() on a port that is already in use by another process. You can't get the port opened, sharing is not possible. To get ahead you need a filter driver that can spy on the way processes use the ports. [Don't write one yourself](https://stackoverflow.com/a/28028450/17034). – Hans Passant Dec 06 '17 at 14:47

0 Answers0