1
private void AddProcess()
2
{
3
int a,b;
4
try
5
{
6
prolist=Process.GetProcesses();
7
}
8
catch(Exception e)
9
{
10
MessageBox.Show(e.Message);
11
}
12
for(int i=0;i<prolist.Length;i++)
13
{
14
b=prolist[i].WorkingSet/1024;
15
a=prolist[i].VirtualMemorySize/1024;
16
listView1.Items.Add(new ListViewItem(new string[]{prolist[i].ProcessName,
17
prolist[i].Id.ToString(),
18
prolist[i].TotalProcessorTime.ToString(),prolist[i].BasePriority.ToString(),
19
b.ToString()+"k",a.ToString()+"k"}));
20
}
21
}
22
23
private void button1_Click(object sender, System.EventArgs e)
24
{
25
for(int i=listView1.SelectedItems.Count-1;i>=0;i--)
26
{
27
ListViewItem li=listView1.SelectedItems[i];
28
for(int j=0;j<prolist.Length;j++)
29
{
30
if(prolist[j].ProcessName==li.Text)
31
prolist[j].Kill();
32
}
33
listView1.Items.Remove(li);
34
}
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
button1 is the method of close process,btw:do not try to close the key process!!!!!
prolist is the process array ,define:
private Process[] prolist=new Process[100]; //LOL
浙公网安备 33010602011771号