Beispiel #1
0
 private void Safesystem1_Load(object sender, EventArgs e)
 {
     this.BackColor = Color.Transparent;
     if (WMIFunc.GetSerialPort(PortName) != "")
     {
         SerialPortOpen();
         timer1.Enabled = true;
     }
 }
Beispiel #2
0
 public void SerialPortOpen()
 {
     comm.BaudRate = 9600;
     comm.PortName = WMIFunc.GetSerialPort(PortName);
     try
     {
         comm.Open();
     }
     catch
     {
         //捕获到异常信息,创建一个新的comm对象,之前的不能用了。
         comm = new SerialPort();
     }
 }