计算机操作系统课程设计-进程管理器.doc_第1页
计算机操作系统课程设计-进程管理器.doc_第2页
计算机操作系统课程设计-进程管理器.doc_第3页
计算机操作系统课程设计-进程管理器.doc_第4页
计算机操作系统课程设计-进程管理器.doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

东北大学秦皇岛分校计算机与通信工程学院计算机操作系统课程设计进程管理器专业名称计算机科学与技术班级学号学生姓名指导教师王翠荣设计时间2012-12-292013-1-10课程设计任务书一、设计题目进程管理器的模拟实现二、主要内容1、目的:编程模拟实现进程管理器,加深对进程、程序概念掌握. 2、进程管理器(1)源代码: Form1.cs Form1.Designer.csnamespace CourseManage partial class Form1 / / 必需的设计器变量。 / private System.ComponentModel.IContainer components = null; / / 清理所有正在使用的资源。 / / 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose(bool disposing) if (disposing & (components != null) components.Dispose(); base.Dispose(disposing); #region Windows 窗体设计器生成的代码 / / 设计器支持所需的方法 - 不要 / 使用代码编辑器修改此方法的内容。 / private void InitializeComponent() ponents = new System.ComponentModel.Container(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(ponents); this.刷新ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.结束进程ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.设置优先级ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.实时ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.高ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.高于标准ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.标准ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.低于标准ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.低ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.listView1 = new System.Windows.Forms.ListView(); this.columnHeader11 = new System.Windows.Forms.ColumnHeader(); this.columnHeader12 = new System.Windows.Forms.ColumnHeader(); this.columnHeader13 = new System.Windows.Forms.ColumnHeader(); this.columnHeader14 = new System.Windows.Forms.ColumnHeader(); this.columnHeader15 = new System.Windows.Forms.ColumnHeader(); this.columnHeader16 = new System.Windows.Forms.ColumnHeader(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.tsslInfo = new System.Windows.Forms.ToolStripStatusLabel(); this.contextMenuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); / / contextMenuStrip1 / this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem this.刷新ToolStripMenuItem, this.结束进程ToolStripMenuItem, this.设置优先级ToolStripMenuItem); this.contextMenuStrip1.Name = contextMenuStrip1; this.contextMenuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; this.contextMenuStrip1.ShowImageMargin = false; this.contextMenuStrip1.ShowItemToolTips = false; this.contextMenuStrip1.Size = new System.Drawing.Size(106, 70); / / 刷新ToolStripMenuItem / this.刷新ToolStripMenuItem.Name = 刷新ToolStripMenuItem; this.刷新ToolStripMenuItem.Size = new System.Drawing.Size(105, 22); this.刷新ToolStripMenuItem.Text = 刷新; this.刷新ToolStripMenuItem.Click += new System.EventHandler(this.刷新ToolStripMenuItem_Click); / / 结束进程ToolStripMenuItem / this.结束进程ToolStripMenuItem.Name = 结束进程ToolStripMenuItem; this.结束进程ToolStripMenuItem.Size = new System.Drawing.Size(105, 22); this.结束进程ToolStripMenuItem.Text = 结束进程; this.结束进程ToolStripMenuItem.Click += new System.EventHandler(this.结束进程ToolStripMenuItem_Click); / / 设置优先级ToolStripMenuItem / this.设置优先级ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem this.实时ToolStripMenuItem, this.高ToolStripMenuItem, this.高于标准ToolStripMenuItem, this.标准ToolStripMenuItem, this.低于标准ToolStripMenuItem, this.低ToolStripMenuItem); this.设置优先级ToolStripMenuItem.Name = 设置优先级ToolStripMenuItem; this.设置优先级ToolStripMenuItem.Size = new System.Drawing.Size(105, 22); this.设置优先级ToolStripMenuItem.Text = 设置优先级; / / 实时ToolStripMenuItem / this.实时ToolStripMenuItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.实时ToolStripMenuItem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.实时ToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.实时ToolStripMenuItem.Name = 实时ToolStripMenuItem; this.实时ToolStripMenuItem.RightToLeft = System.Windows.Forms.RightToLeft.No; this.实时ToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.实时ToolStripMenuItem.Text = 实时; this.实时ToolStripMenuItem.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.实时ToolStripMenuItem.Click += new System.EventHandler(this.实时ToolStripMenuItem_Click); / / 高ToolStripMenuItem / this.高ToolStripMenuItem.Name = 高ToolStripMenuItem; this.高ToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.高ToolStripMenuItem.Text = 高; this.高ToolStripMenuItem.Click += new System.EventHandler(this.高ToolStripMenuItem_Click); / / 高于标准ToolStripMenuItem / this.高于标准ToolStripMenuItem.Name = 高于标准ToolStripMenuItem; this.高于标准ToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.高于标准ToolStripMenuItem.Text = 高于标准; this.高于标准ToolStripMenuItem.Click += new System.EventHandler(this.高于标准ToolStripMenuItem_Click); / / 标准ToolStripMenuItem / this.标准ToolStripMenuItem.Name = 标准ToolStripMenuItem; this.标准ToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.标准ToolStripMenuItem.Text = 标准; this.标准ToolStripMenuItem.Click += new System.EventHandler(this.标准ToolStripMenuItem_Click); / / 低于标准ToolStripMenuItem / this.低于标准ToolStripMenuItem.Name = 低于标准ToolStripMenuItem; this.低于标准ToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.低于标准ToolStripMenuItem.Text = 低于标准; this.低于标准ToolStripMenuItem.Click += new System.EventHandler(this.低于标准ToolStripMenuItem_Click); / / 低ToolStripMenuItem / this.低ToolStripMenuItem.Name = 低ToolStripMenuItem; this.低ToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.低ToolStripMenuItem.Text = 低; this.低ToolStripMenuItem.Click += new System.EventHandler(this.低ToolStripMenuItem_Click); / / tabControl1 / this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = tabControl1; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(469, 314); this.tabControl1.TabIndex = 6; / / tabPage1 / this.tabPage1.Controls.Add(this.listView1); this.tabPage1.Location = new System.Drawing.Point(4, 21); this.tabPage1.Name = tabPage1; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.tabPage1.Size = new System.Drawing.Size(461, 289); this.tabPage1.TabIndex = 0; this.tabPage1.Text = 进程; this.tabPage1.UseVisualStyleBackColor = true; / / listView1 / this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader this.columnHeader11, this.columnHeader12, this.columnHeader13, this.columnHeader14, this.columnHeader15, this.columnHeader16); this.listView1.ContextMenuStrip = this.contextMenuStrip1; this.listView1.Dock = System.Windows.Forms.DockStyle.Fill; this.listView1.FullRowSelect = true; this.listView1.GridLines = true; this.listView1.Location = new System.Drawing.Point(3, 3); this.listView1.Name = listView1; this.listView1.Size = new System.Drawing.Size(455, 283); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.View = System.Windows.Forms.View.Details; / / columnHeader11 / this.columnHeader11.Text = 映像名称; this.columnHeader11.Width = 100; / / columnHeader12 / this.columnHeader12.Text = 进程ID; this.columnHeader12.Width = 70; / / columnHeader13 / this.columnHeader13.Text = 线程数; this.columnHeader13.Width = 70; / / columnHeader14 / this.columnHeader14.Text = 优先级; / / columnHeader15 / this.columnHeader15.Text = 物理内存; this.columnHeader15.Width = 65; / / columnHeader16 / this.columnHeader16.Text = 虚拟内存; this.columnHeader16.Width = 85; / / statusStrip1 / this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem this.tsslInfo); this.statusStrip1.Location = new System.Drawing.Point(0, 314); this.statusStrip1.Name = statusStrip1; this.statusStrip1.Size = new System.Drawing.Size(469, 22); this.statusStrip1.TabIndex = 7; this.statusStrip1.Text = statusStrip1; / / tsslInfo / this.tsslInfo.Name = tsslInfo; this.tsslInfo.Size = new System.Drawing.Size(131, 17); this.tsslInfo.Text = toolStripStatusLabel1; / / Form1 / this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(469, 336); this.Controls.Add(this.tabControl1); this.Controls.Add(this.statusStrip1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = Form1; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = 进程管理器; this.Load += new System.EventHandler(this.Form1_Load); this.contextMenuStrip1.ResumeLayout(false); this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); #endregion private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ToolStripMenuItem 刷新ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 结束进程ToolStripMenuItem; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.ListView listView1; private System.Windows.Forms.ColumnHeader columnHeader11; private System.Windows.Forms.ColumnHeader columnHeader12; private System.Windows.Forms.ColumnHeader columnHeader13; private System.Windows.Forms.ColumnHeader columnHeader14; private System.Windows.Forms.ColumnHeader columnHeader15; private System.Windows.Forms.ColumnHeader columnHeader16; private System.Windows.Forms.ToolStripMenuItem 设置优先级ToolStripMenuItem; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel tsslInfo; private System.Windows.Forms.ToolStripMenuItem 实时ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 高ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 高于标准ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 标准ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 低于标准ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 低ToolStripMenuItem; From1.resx Form1using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Diagnostics;using System.Management;using System.Runtime.InteropServices;namespace CourseManage public partial class Form1 : Form public Form1() InitializeComponent(); private void getProcessInfo() try listView1.Items.Clear(); Process MyProcesses = Process.GetProcesses(); tsslInfo.Text = 进程总数: + MyProcesses.Length.ToString(); string Minfo = new string6; foreach (Process MyProcess in MyProcesses) Minfo0 = MyProcess.ProcessName; Minfo1 = MyProcess.MainModule.ModuleName; Minfo2 = MyProcess.Threads.Count.ToString(); Minfo3 = MyProcess.BasePriority.ToString(); Minfo4 = Convert.ToString(MyProcess.WorkingSet / 1024) + K; Minfo5 = Convert.ToString(MyProcess.VirtualMemorySize / 1024) + K; ListViewItem lvi = new ListViewItem(Minfo, process); listView1.Items.Add(lvi); catch private void Form1_Load(object sender, EventArgs e) getProcessInfo(); private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e) getProcessInfo(); private void 结束进程ToolStripMenuItem_Click(object sender, EventArgs e) try if (MessageBox.Show(警告:终止进程会导致不希望发生的结果,r包括数据丢失和系统不稳定。在被终止前,r进程将没有机会保存其状态和数据。确实r想终止该进程吗?, 任务管理器警告, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = DialogResult.Yes) string ProcessName = listView1.SelectedItems0.Text; Process MyProcess = Process.GetProcessesByName(ProcessName); MyProcess0.Kill(); getProcessInfo(); else catch string ProcessName = listView1.SelectedItems0.Text; Process MyProcess1 = Process.GetProcessesByName(ProcessName); Process MyProcess = new Process(); /设定程序名 MyProcess.StartInfo.FileName = cmd.exe; /关闭Shell的使用 MyProcess.StartInfo.UseShellExecute = false; /重定向标准输入 MyProcess.StartInfo.RedirectStandardInput = true; /重定向标准输出 MyProcess.StartInfo.RedirectStandardOutput = true; /重定向错误输出 MyProcess.StartInfo.RedirectStandardError = true; /设置不显示窗口 MyProcess.StartInfo.CreateNoWindow = true; /执行强制结束命令 MyProcess.Start(); MyProcess.StandardInput.WriteLine(ntsd -c q -p + (MyProcess10.Id).ToString(); MyProcess.StandardInput.WriteLine(Exit); getProcessInfo(); private void SetBasePriority(int i) string ProcessName = listView1.SelectedItems0.Text; Process MyProcess = Process.GetProcessesByName(ProcessName); switch (i) case 0: MyProcess0.PriorityClass = ProcessPriorityClass.Idle; break;/低 ca

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论