如何用C#获得电脑上串口信息(存在哪几个串口设备)?

解决方案 »

  1.   

    连续 createfile就可以了。哈哈。
      

  2.   

    http://msmvps.com/coad/archive/2005/03/23/39466.aspx
      

  3.   

    // This is a new namespace in .NET 2.0 that contains the SerialPort class
    using System.IO.Ports;private static void SendSampleData()
    {
      // Instantiate the communications port with some basic settings
      SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
      
      // Open the port for communications
      port.Open();
      
      // Write a string
      port.Write("Hello World");
      
      // Write a set of bytes
      port.Write(new byte[] {0x0A, 0xE2, 0xFF}, 0, 3);
      
      // Close the port
      port.Close();
    }