www.pudn.com > MyProcess.rar > Form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;
namespace MyProcess
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.Windows.Forms.ToolBarButton toolBarButton5;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Panel panel7;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.ListView listView3;
private System.Windows.Forms.ColumnHeader columnHeader9;
private System.Windows.Forms.ColumnHeader columnHeader10;
private System.Windows.Forms.ListView listView4;
private System.Windows.Forms.ColumnHeader columnHeader11;
private System.Windows.Forms.ColumnHeader columnHeader12;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.ColumnHeader columnHeader13;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.ImageList imageList1;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.MenuItem menuItem10;
private Form2 form2Example;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
UpdateProcess();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.panel4 = new System.Windows.Forms.Panel();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader13 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel5 = new System.Windows.Forms.Panel();
this.panel7 = new System.Windows.Forms.Panel();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.panel6 = new System.Windows.Forms.Panel();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.listView4 = new System.Windows.Forms.ListView();
this.columnHeader11 = new System.Windows.Forms.ColumnHeader();
this.columnHeader12 = new System.Windows.Forms.ColumnHeader();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.listView3 = new System.Windows.Forms.ListView();
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.panel1.SuspendLayout();
this.panel3.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.panel7.SuspendLayout();
this.groupBox5.SuspendLayout();
this.panel6.SuspendLayout();
this.groupBox4.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage3.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem10});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6,
this.menuItem7,
this.menuItem8,
this.menuItem9});
this.menuItem1.Text = "进程管理(&G)";
//
// menuItem6
//
this.menuItem6.Index = 0;
this.menuItem6.Text = "刷新 (&F)";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 1;
this.menuItem7.Text = "终止 (&Z)";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem8
//
this.menuItem8.Index = 2;
this.menuItem8.Text = "-";
//
// menuItem9
//
this.menuItem9.Index = 3;
this.menuItem9.Text = "退出 (&X)";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuItem4,
this.menuItem5});
this.menuItem2.Text = "帮助(&H)";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Text = "帮助 (&H)";
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "-";
//
// menuItem5
//
this.menuItem5.Index = 2;
this.menuItem5.Text = "关于 (&A)";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2,
this.toolBarButton3,
this.toolBarButton4,
this.toolBarButton5});
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(672, 41);
this.toolBar1.TabIndex = 0;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 0;
this.toolBarButton1.Text = "退出";
//
// toolBarButton2
//
this.toolBarButton2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton3
//
this.toolBarButton3.ImageIndex = 1;
this.toolBarButton3.Text = "刷新";
//
// toolBarButton4
//
this.toolBarButton4.ImageIndex = 2;
this.toolBarButton4.Text = "终止";
//
// toolBarButton5
//
this.toolBarButton5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Left;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(344, 31);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Left;
this.label1.Location = new System.Drawing.Point(3, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 11);
this.label1.TabIndex = 0;
this.label1.Text = "进程列表";
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Left;
this.label2.Location = new System.Drawing.Point(3, 17);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 11);
this.label2.TabIndex = 1;
this.label2.Text = "进程数:";
//
// label3
//
this.label3.Dock = System.Windows.Forms.DockStyle.Left;
this.label3.Location = new System.Drawing.Point(3, 17);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(197, 11);
this.label3.TabIndex = 2;
this.label3.Text = "合计占用内存:";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox2.Location = new System.Drawing.Point(0, 0);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(216, 31);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox3.Location = new System.Drawing.Point(344, 0);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(136, 31);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
//
// panel1
//
this.panel1.Controls.Add(this.panel3);
this.panel1.Controls.Add(this.panel2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 41);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(672, 31);
this.panel1.TabIndex = 5;
//
// panel3
//
this.panel3.Controls.Add(this.groupBox2);
this.panel3.Dock = System.Windows.Forms.DockStyle.Right;
this.panel3.Location = new System.Drawing.Point(456, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(216, 31);
this.panel3.TabIndex = 3;
//
// panel2
//
this.panel2.Controls.Add(this.groupBox1);
this.panel2.Controls.Add(this.groupBox3);
this.panel2.Dock = System.Windows.Forms.DockStyle.Left;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(480, 31);
this.panel2.TabIndex = 2;
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 473);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(672, 20);
this.statusBar1.TabIndex = 6;
//
// statusBarPanel1
//
this.statusBarPanel1.Width = 550;
//
// statusBarPanel2
//
this.statusBarPanel2.Text = "版权所有 DW";
//
// panel4
//
this.panel4.Controls.Add(this.listView1);
this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
this.panel4.Location = new System.Drawing.Point(0, 72);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(672, 152);
this.panel4.TabIndex = 7;
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader13,
this.columnHeader4,
this.columnHeader5,
this.columnHeader6});
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(672, 152);
this.listView1.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listView1.TabIndex = 0;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.Click += new System.EventHandler(this.listView1_Click);
//
// columnHeader1
//
this.columnHeader1.Text = "进程名";
this.columnHeader1.Width = 135;
//
// columnHeader2
//
this.columnHeader2.Text = "PID";
//
// columnHeader3
//
this.columnHeader3.Text = "优先级";
this.columnHeader3.Width = 80;
//
// columnHeader13
//
this.columnHeader13.Text = "线程数";
this.columnHeader13.Width = 70;
//
// columnHeader4
//
this.columnHeader4.Text = "占用内存";
this.columnHeader4.Width = 100;
//
// columnHeader5
//
this.columnHeader5.Text = "CPU占用时间";
this.columnHeader5.Width = 100;
//
// columnHeader6
//
this.columnHeader6.Text = "启动时间";
this.columnHeader6.Width = 100;
//
// splitter1
//
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 224);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(672, 3);
this.splitter1.TabIndex = 8;
this.splitter1.TabStop = false;
//
// panel5
//
this.panel5.Controls.Add(this.panel7);
this.panel5.Controls.Add(this.panel6);
this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
this.panel5.Location = new System.Drawing.Point(0, 227);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(672, 31);
this.panel5.TabIndex = 9;
//
// panel7
//
this.panel7.Controls.Add(this.groupBox5);
this.panel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel7.Location = new System.Drawing.Point(456, 0);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(216, 31);
this.panel7.TabIndex = 1;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.label5);
this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox5.Location = new System.Drawing.Point(0, 0);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(216, 31);
this.groupBox5.TabIndex = 0;
this.groupBox5.TabStop = false;
//
// label5
//
this.label5.Dock = System.Windows.Forms.DockStyle.Fill;
this.label5.Location = new System.Drawing.Point(3, 17);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(210, 11);
this.label5.TabIndex = 0;
//
// panel6
//
this.panel6.Controls.Add(this.groupBox4);
this.panel6.Dock = System.Windows.Forms.DockStyle.Left;
this.panel6.Location = new System.Drawing.Point(0, 0);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(456, 31);
this.panel6.TabIndex = 0;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label4);
this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox4.Location = new System.Drawing.Point(0, 0);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(456, 31);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
//
// label4
//
this.label4.Dock = System.Windows.Forms.DockStyle.Fill;
this.label4.Location = new System.Drawing.Point(3, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(450, 11);
this.label4.TabIndex = 0;
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 258);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(672, 215);
this.tabControl1.TabIndex = 10;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.listView4);
this.tabPage3.Location = new System.Drawing.Point(4, 21);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(664, 190);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "内存信息";
//
// listView4
//
this.listView4.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader11,
this.columnHeader12});
this.listView4.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView4.FullRowSelect = true;
this.listView4.Location = new System.Drawing.Point(0, 0);
this.listView4.MultiSelect = false;
this.listView4.Name = "listView4";
this.listView4.Size = new System.Drawing.Size(664, 190);
this.listView4.TabIndex = 0;
this.listView4.View = System.Windows.Forms.View.Details;
//
// columnHeader11
//
this.columnHeader11.Text = "内存使用类别";
this.columnHeader11.Width = 300;
//
// columnHeader12
//
this.columnHeader12.Text = "大小";
this.columnHeader12.Width = 100;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.listView3);
this.tabPage2.Location = new System.Drawing.Point(4, 21);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(664, 190);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "模块信息";
//
// listView3
//
this.listView3.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader9,
this.columnHeader10});
this.listView3.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView3.FullRowSelect = true;
this.listView3.Location = new System.Drawing.Point(0, 0);
this.listView3.MultiSelect = false;
this.listView3.Name = "listView3";
this.listView3.Size = new System.Drawing.Size(664, 190);
this.listView3.TabIndex = 0;
this.listView3.View = System.Windows.Forms.View.Details;
//
// columnHeader9
//
this.columnHeader9.Text = "模块名称";
this.columnHeader9.Width = 200;
//
// columnHeader10
//
this.columnHeader10.Text = "模块大小";
this.columnHeader10.Width = 100;
//
// menuItem10
//
this.menuItem10.Index = 2;
this.menuItem10.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(672, 493);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.panel5);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel4);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.toolBar1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(680, 520);
this.Menu = this.mainMenu1;
this.MinimumSize = new System.Drawing.Size(680, 520);
this.Name = "Form1";
this.Text = "MyProcess进程管理器";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
this.panel4.ResumeLayout(false);
this.panel5.ResumeLayout(false);
this.panel7.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.panel6.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void OnProcessExited(object sender,EventArgs e)
{
UpdateProcess();
}
private void UpdateProcess()
{
string processName;
int processID;
int threadNum;
TimeSpan cpuTime;
int memory;
int priorityNumber;
DateTime startTime;
Process[] processes=Process.GetProcesses();
int summemory=0;
if (this.listView1!=null)
{
this.listView1.Items.Clear();
}
for(int i=0;i0)
{
int processID=Int32.Parse(listView1.SelectedItems[0].SubItems[1].Text );
Process selectedProcess=Process.GetProcessById(processID);
selectedProcess.EnableRaisingEvents=true;
selectedProcess.Exited+=new EventHandler(OnProcessExited);
if(!selectedProcess.HasExited )
{
if(!selectedProcess.CloseMainWindow())
{
if(MessageBox.Show("不能关闭应用程序窗口,需要继续终止进程吗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question )==DialogResult.Yes )
{
try
{
selectedProcess.Kill();
}
catch
{
MessageBox.Show("不能结束进程!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error );
}
}
}
else
{
MessageBox.Show("选中进程已退出!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information );
UpdateProcess();
}
}
}
else
{
MessageBox.Show("请先选中一个当前正在运行的进程!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information );
}
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (e.Button==this.toolBarButton1)
{
this.Close();
}
if (e.Button==this.toolBarButton3 )
{
UpdateProcess();
}
if (e.Button==this.toolBarButton4 )
{
KillProcess();
}
}
private void DisplayModules(int processId)
{
Process NowProcess;
ProcessModuleCollection modules;
NowProcess=Process.GetProcessById(processId);
modules=NowProcess.Modules;
if (this.listView3!=null)
{
this.listView3.Items.Clear();
}
foreach(ProcessModule aModule in modules)
{
string[] subItems={
aModule.ModuleName,
string.Format("{0:#,#,#}KB",aModule.ModuleMemorySize/1024)
};
ListViewItem item=new ListViewItem(subItems);
this.listView3.Items.Insert(0,item);
}
}
private void DisplayMemory(int processId)
{
Process NowProcess;
NowProcess=Process.GetProcessById(processId);
if (this.listView4!=null)
{
this.listView4.Items.Clear();
}
//获取专用内存大小
int PrivateMemory=NowProcess.PrivateMemorySize;
string[] Subitem={"专用内存大小",(PrivateMemory/1024).ToString()+"K"};
ListViewItem item=new ListViewItem(Subitem);
this.listView4.Items.Add(item);
//获取峰值虚拟内存大小
int peakvirtualMemory=NowProcess.PeakVirtualMemorySize;
string[] Subitem1={"峰值虚拟内存大小",(peakvirtualMemory/1024).ToString()+"KB"};
ListViewItem item1=new ListViewItem(Subitem1);
this.listView4.Items.Add(item1);
//获取峰值分页内存大小
int peakpageMemory=NowProcess.PeakPagedMemorySize;
string[] Subitem2={"峰值分页内存大小",(peakpageMemory/1024).ToString()+"KB"};
ListViewItem item2=new ListViewItem(Subitem2);
this.listView4.Items.Add(item2);
//获取分页系统内存大小
int pageSystemMemory=NowProcess.PagedSystemMemorySize;
string[] Subitem3={"分页系统内存大小",(pageSystemMemory/1024).ToString()+"KB"};
ListViewItem item3=new ListViewItem(Subitem3);
this.listView4.Items.Add(item3);
//获取分页内存大小
int pageMemory=NowProcess.PagedMemorySize;
string[] Subitem4={"分页内存大小",(pageMemory/1024).ToString()+"KB"};
ListViewItem item4=new ListViewItem(Subitem4);
this.listView4.Items.Add(item4);
//获取未分页的系统内存大小
int nonpageSystemMemory=NowProcess.NonpagedSystemMemorySize;
string[] Subitem5={"未分页的系统内存大小",(nonpageSystemMemory/1024).ToString()+"KB"};
ListViewItem item5=new ListViewItem(Subitem5);
this.listView4.Items.Add(item5);
//获取物理内存大小
int memory=NowProcess.WorkingSet;
string[] Subitem6={"物理内存大小",(memory/1024).ToString()+"KB"};
ListViewItem item6=new ListViewItem(Subitem6);
this.listView4.Items.Add(item6);
//获取进程的虚拟内存大小
int virtualmemory=NowProcess.VirtualMemorySize;
string[] Subitem7={"虚拟内存大小",(virtualmemory/1024).ToString()+"KB"};
ListViewItem item7=new ListViewItem(Subitem7);
this.listView4.Items.Add(item7);
}
private void listView1_Click(object sender, System.EventArgs e)
{
if(this.listView1.SelectedItems.Count>0)
{
int processID=Int32.Parse(listView1.SelectedItems[0].SubItems[1].Text );
Process NowProcess;
NowProcess=Process.GetProcessById(processID);
string processName=NowProcess.ProcessName;
this.label4.Text=processName+"的详细信息:";
try
{
DisplayModules(processID);
DisplayMemory(processID);
}
catch
{
if (this.listView3!=null)
{
this.listView3.Items.Clear();
}
if (this.listView4!=null)
{
this.listView4.Items.Clear();
}
}
}
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
UpdateProcess();
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
KillProcess();
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
form2Example=new Form2();
form2Example.Visible=true;
}
}
}