コード例 #1
0
 private void Button3_Click_1(object sender, EventArgs e)
 {
     if (RealDetection)
     {
         try
         {
             RealDetection = false;
             monitor.Abort();
             button3.Text = PROGRAM_STRING.RD_BUTTON_OFF;
             listView1.Items.Add(PROGRAM_STRING.RDOFF);
         }catch (Exception)
         {
             ;
         }
     }
     else
     {
         try
         {
             RealDetection = true;
             monitor.Run();
             button3.Text = PROGRAM_STRING.RD_BUTTON_ON;
         }
         catch (Exception)
         {
             ;
         }
     }
 }
コード例 #2
0
        protected override void ThreadProc()
        {
            try
            {
                listview.Invoke(
                    new Form1.Delegate_ListViewUpdate(
                        Update_ListView),
                    new object[] { PROGRAM_STRING.RDON }
                    );
            }catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            while (true)
            {
                try
                {
                    PProcess pProcess = new PProcess();
                    pProcess.Initialize();
                    int pid = MonitorThraed.Run(Encoding.Default.GetBytes(DevicePDO));

                    if (pid > 0)
                    {
                        string pName   = pProcess.GetProcessNameFromID(pid);
                        string sDetect = pName + "에서 탐지되었습니다.";

                        listview.Invoke(
                            new Form1.Delegate_ListViewUpdate(
                                Update_ListView),
                            new object[] { sDetect }
                            );

                        if (MessageBox.Show(sDetect + "\n종료하시겠습니까?", "경고", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            PProcess.KillProcess(pid);
                        }
                        else
                        {
                            ;
                        }
                    }
                }
                catch (ManagementException)
                {
                    return;
                }
                catch (ThreadInterruptedException)
                {
                    return;
                }
                catch (ThreadAbortException)
                {
                    return;
                }
            }
        }