Ejemplo n.º 1
0
 private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     e.Cancel         = true;
     this.WindowState = FormWindowState.Minimized;
     if (serverFrm != null)
     {
         serverFrm.Hide();
     }
     this.Visible = false;
     this.Hide();
     this.ShowInTaskbar = false;
     this.nIcon.Visible = true;
     //关闭密码器
     if (m_UsbPwsSupport == "1")
     {
         try
         {
             int nDeviceHandle = (int)phDeviceHandle;
             int nReturn       = usb.USB_CloseDevice(ref nDeviceHandle);
         }
         catch (Exception em)
         {
             MessageBox.Show("密码器关闭失败:" + em.Message);
         }
     }
     //GC.Collect();
 }
Ejemplo n.º 2
0
 private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     e.Cancel         = true;
     this.WindowState = FormWindowState.Minimized;
     if (serverFrm != null)
     {
         serverFrm.Hide();
     }
     this.Visible = false;
     this.Hide();
     this.ShowInTaskbar = false;
     this.nIcon.Visible = true;
     //关闭密码器  丽水松阳项目不使用此密码器   20180227
     //if (m_UsbPwsSupport == "1")
     //{
     //    try
     //    {
     //        int nDeviceHandle = (int)phDeviceHandle;
     //        int nReturn = usb.USB_CloseDevice(ref nDeviceHandle);
     //    }
     //    catch (Exception em)
     //    {
     //        MessageBox.Show("密码器关闭失败:" + em.Message);
     //    }
     //}
     if (serverFrm != null)
     {
         serverFrm.Close();
         serverFrm.Dispose();
     }
     if (comm != null)
     {
         comm.Close();
         comm.Dispose();
     }
     if (sndComm != null)
     {
         sndComm.Close();
         sndComm.Dispose();
     }
     this.Dispose();                //释放资源
     Application.Exit();
     Application.ExitThread();
     Environment.Exit(0);
 }