3

I can currently read and write to my serial ports on the machine, but I wish to be able to change from, for example, COM3 to COM4 within my program. I can't find a way to do this online - I've seen you can potentially use Windows Developer Kit but unsure as to whether that can be used with C#? Thanks.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
danny10846
  • 131
  • 9
  • 1
    Please refer to this article and its references. [Change COM port via registry, command line or software?](https://stackoverflow.com/q/2002890/9014308) – kunif Jan 07 '19 at 09:35
  • It seems there is no .net api, but you can of course use P/Invoke to use another API. – Ben Jan 07 '19 at 09:40
  • Are you trying to change the I/O address of the port or just select different port number? The port number is a string and can be change simply by changing from "COM3" to "COM4". See msdn : https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.-ctor?view=netframework-4.7.2 – jdweng Jan 07 '19 at 09:56

0 Answers0