コード例 #1
0
 /* override system windows message of Serial put in or pull out */
 protected override void DefWndProc(ref Message m)
 {
     if (m.Msg == (int)WMS.WM_DEVICECHANGE)                             //device state change, put in or pull out
     {
         if (m.WParam.ToInt32() == (Int32)DBT.DBT_DEVICEREMOVECOMPLETE) //USB serial device remove
         {
             btnChangeCloseUartUI();
             com.ClearUIAsyncHandle();
             dsPortName.DataSource = SelfdefSerial.GetPortNames();
         }
         else if (m.WParam.ToInt32() == (Int32)DBT.DBT_DEVICEARRIVAL)   //USB serial device put in
         {
             dsPortName.DataSource = SelfdefSerial.GetPortNames();
         }
     }
     base.DefWndProc(ref m);
 }
コード例 #2
0
 private void dsPortName_DropDown(object sender, EventArgs e)
 {
     string [] portname = SelfdefSerial.GetPortNames();
     dsPortName.DataSource = portname;
 }