using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace FindProcess
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process[] pro = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process IsProcedding in pro)
{
this.listBox1.Items.Add(IsProcedding.ProcessName.ToString());
}
this.timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
System.Diagnostics.Process[] pro1 = System.Diagnostics.Process.GetProcesses();
bool find ;
foreach (System.Diagnostics.Process IsProcedding in pro1)
{
find = false;
for (int i = 0; i <= this.listBox1.Items.Count-1; i++)
{
if (this.listBox1.Items[i].ToString() == IsProcedding.ProcessName.ToString())
{
find = true;
}
}
if (find == false)
{
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
this.listBox2.Items.Add("进程名:"+IsProcedding.ProcessName.ToString()+"--启动时间:"+currentTime.ToString());
this.listBox1.Items.Add(IsProcedding.ProcessName.ToString());
}
}
}
}
}