tags:

views:

41

answers:

2

How can I change the speed (bits per second) of the COM port on my machine using C# or the Win32 API via PInvoke?

I would like to do this instead of going into the properties of the COM port in device manager.

+1  A: 

Why not use the SerialPort class?

SB
+1  A: 

as SB said, using the C# SerialPort class:

class Run
{
  public static void main(string[] args)
  {
    SerialPort port = new SerialPort("COM2", 115200);
    port.BaudRate = 115200; // set it elsewhere.
    port.Open();
    port.Write("ABCDE");
  }
}
FallingBullets
Will this set it globally or just for my connection?.I wish to set it for all applications that will use it.
hollyghost
no, http://bytes.com/topic/c-sharp/answers/252578-serial-port#post1019247 <- but that might work
FallingBullets