softairhk

softairhk

  • NA
  • 115
  • 0

Windows 2000 like Processes Manager

Oct 6 2003 10:53 PM
Hello! I got a Windows 2000 like Processes Manager, but I would like to change something on the coding: Requirement: How to add an automatic refreshing function for the Processes Manager, now it need to press the "Refresh" button? Please modify on the coding listed on below directly. Thanks! using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Diagnostics; namespace ProcessTracker { /// /// Form 1 Description /// public class Processes : System.Windows.Forms.Form { private System.Windows.Forms.ListView listView1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; 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; /// /// Necessary Components /// private System.ComponentModel.Container components = null; private System.Windows.Forms.StatusBar statusBar1; private System.Windows.Forms.StatusBarPanel statusBarPanel1; private System.Windows.Forms.StatusBarPanel statusBarPanel2; private System.Diagnostics.Process[] prolist=new System.Diagnostics.Process[100]; public Processes() { // // Windows Form // InitializeComponent(); // // TODO: InitializeComponent // } /// /// Clear all necessary resources /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Generated Code /// /// Necessary Method /// Supported Method /// private void InitializeComponent() { 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.columnHeader4 = new System.Windows.Forms.ColumnHeader(); this.columnHeader5 = new System.Windows.Forms.ColumnHeader(); this.columnHeader6 = new System.Windows.Forms.ColumnHeader(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.statusBar1 = new System.Windows.Forms.StatusBar(); this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel(); this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit(); this.SuspendLayout(); // // listView1 // this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader2, this.columnHeader3, this.columnHeader4, this.columnHeader5, this.columnHeader6}); this.listView1.FullRowSelect = true; this.listView1.GridLines = true; this.listView1.HideSelection = false; this.listView1.Location = new System.Drawing.Point(0, 0); this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(433, 288); this.listView1.TabIndex = 0; this.listView1.View = System.Windows.Forms.View.Details; // // columnHeader1 // this.columnHeader1.Text = "Process Name"; this.columnHeader1.Width = 94; // // columnHeader2 // this.columnHeader2.Text = "PID"; this.columnHeader2.Width = 51; // // columnHeader3 // this.columnHeader3.Text = "CPU"; this.columnHeader3.Width = 53; // // columnHeader4 // this.columnHeader4.Text = "Priority"; // // columnHeader5 // this.columnHeader5.Text = "Mem Usage"; this.columnHeader5.Width = 69; // // columnHeader6 // this.columnHeader6.Text = "Virtual Mem"; this.columnHeader6.Width = 86; // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button1.Location = new System.Drawing.Point(246, 296); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 24); this.button1.TabIndex = 1; this.button1.Text = "Refresh"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button2.Location = new System.Drawing.Point(342, 296); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(80, 24); this.button2.TabIndex = 2; this.button2.Text = "End Process"; this.button2.Click += new System.EventHandler(this.button2_Click); // // statusBar1 // this.statusBar1.Location = new System.Drawing.Point(0, 324); 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(432, 22); this.statusBar1.TabIndex = 3; this.statusBar1.Text = "statusBar1"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(432, 346); this.Controls.Add(this.statusBar1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.listView1); this.MaximizeBox = false; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Running Processes"; this.Load += new System.EventHandler(this.Processes_Load); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit(); this.ResumeLayout(false); } #endregion /// /// Application Entry Point /// [STAThread] static void Main() { Application.Run(new Processes()); } //Create Process Group private void list() { try { prolist=Process.GetProcesses(); } catch(Exception e) { MessageBox.Show(e.Message); } } //Add Process into ListView private void addprocess() { int ivirtual,iphysical; for(int i=0;i0) { //int i=listView1.SelectedItems.Count; ListViewItem li=listView1.SelectedItems[0]; for(int j=0;j

Answers (4)