Пример #1
0
        protected override void WndProc(ref Message m)
        {
            int mess = mdisk.MessageResult(m);

            if (mess == 1)
            {
                try
                {
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }

                    if (f12 == null)
                    {
                        f12 = new Form12(strList);
                    }
                    else
                    {
                        f12.UpdateForm(strList, f12.Visible);
                    }
                }
                catch (Exception ex)
                {
                    string ss = ex.Message;
                }
            }
            if (mess == 2)
            {
                if (f12 != null)
                {
                    List <string> removelist = new List <string>(strList.ToArray());
                    strList.Clear();
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    int         i      = 0;
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                                DelStrList(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory, removelist);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    f12.Hide();
                    f12.removeUSBFile(removelist);
                    f12.UpdateForm(strList, false);
                }
            }
            base.WndProc(ref m);
        }
Пример #2
0
        private void Exit()
        {
            try
            {
                MyPPT.clearImg();
            }
            catch (Exception e) { Log.Error(e.Message); }

            isExit = true;
            //2016-04-09
            Log.Info("From1.exit now...");
            try
            {
                if (m_db != null)
                {
                    m_db.Close();
                    m_db = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            this.timer_lessonOff.Enabled = false;
            this.ShowInTaskbar           = false;
            this.notifyIcon1.Visible     = false;

            try
            {
                Process p = Process.GetCurrentProcess();
                if (p != null)
                {
                    Log.Info("From1 KillProcess now. pid=" + p.Id);
                    Thread.Sleep(1000);
                    p.Kill();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (m_Host != null)
                {
                    m_Host.Close();
                    m_Host = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (m_HttpdComet != null)
                {
                    m_HttpdComet.stop();
                    m_HttpdComet = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_comet != null)
                {
                    thread_comet.Abort();
                    thread_comet.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_Manage != null)
                {
                    thread_Manage.Abort();
                    thread_Manage.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_DeviceStatusCheck != null)
                {
                    thread_DeviceStatusCheck.Abort();
                    thread_DeviceStatusCheck.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (fNotify != null)
                {
                    fNotify.Close();
                    fNotify = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (f12 != null)
                {
                    f12.Close();
                    f12 = null;
                }
                Application.Exit();
            }
            catch (Exception e) { Log.Error(e.Message); }


            Log.Info("From1 exit over.");
        }