




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
东北大学秦皇岛分校计算机与通信工程学院计算机操作系统课程设计设计题目:进程管理器专业名称计算机科学与技术班级学号xxxx学生姓名xxxx指导教师xxxxx设计时间2014-12-292015-1-15课程设计任务书专业:计算机科学与技术 学号: 学生姓名(签名):设计题目1、高优先权调度算法的模拟2、进程管理器的模拟实现二、主要内容1、目的:编程模拟实现进程管理器,加深对进程、程序概念掌握. 2、进程管理器主界面如下:(1)源代码: Form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Management;using System.Diagnostics;namespace WindowsApplication1 public partial class Form1 : Form public Form1() InitializeComponent(); this.listProcesses.MultiSelect = false; this.listProcesses.View = View.Details; this.listProcesses.Columns.Add(pname,(int)CreateGraphics().MeasureString( aaaaaaaaaaaaaaaaaaaaaa,Font).Width); this.listProcesses.Columns.Add(pID, (int)CreateGraphics().MeasureString( 000000000000, Font).Width); this.listProcesses.Columns.Add(username, (int)CreateGraphics().MeasureString( aaaaaaaaaaaaaaaaaaaaa, Font).Width); this.listProcesses.Columns.Add(priority, (int)CreateGraphics().MeasureString( aaaaaaaaa, Font).Width); this.listProcesses.Columns.Add(Memory usage, (int)CreateGraphics().MeasureString( 000000000000000,Font).Width); private void Form1_Load(object sender, EventArgs e) RefreshList(); private void RefreshList() Process processes; processes = Process.GetProcesses(); this.listProcesses.Items.Clear(); foreach (Process instance in processes) ListViewItem lvi = new ListViewItem(instance.ProcessName); lvi.SubItems.Add(FormatProcessID(instance.Id); lvi.SubItems.Add(GetProcessUserName(instance.Id); lvi.SubItems.Add(instance.BasePriority.ToString(); lvi.SubItems.Add(FormatMemorySize(instance.WorkingSet64); string strToolTip = null; ProcessModuleCollection modules; if (instance.ProcessName.CompareTo(System) != 0 | instance.ProcessName.CompareTo(Idle) != 0) try /当进程不充允枚举模块时会产生异常 modules = instance.Modules; foreach (ProcessModule aModule in modules) strToolTip += aModule.ModuleName; strToolTip += ; ; catch (System.ComponentModel.Win32Exception) lvi.ToolTipText = strToolTip; this.listProcesses.Items.Add(lvi); /格式化内存字符串 private string FormatMemorySize(long lMemorySize) return String.Format(0,8:N0 K, lMemorySize / 1000); private string FormatProcessID(int id) return String.Format(0,8,id); private static string GetProcessUserName(int pID) string text1 = null; SelectQuery query1 = new SelectQuery(Select * from Win32_Process WHERE processID= + pID); ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(query1); try foreach (ManagementObject disk in searcher1.Get() ManagementBaseObject inPar = null; ManagementBaseObject outPar = null; inPar = disk.GetMethodParameters(GetOwner); outPar = disk.InvokeMethod(GetOwner, inPar, null); text1 = outParUser.ToString(); break; catch text1 = SYSTEM; return text1; private void StopProcess_Click(object sender, EventArgs e) Process process = Process.GetProcessById( int.Parse(this.listProcesses.SelectedItems0.SubItems1.Text); process.Kill(); RefreshList(); /释放进程的资源 private void Refresh_Click(object sender, EventArgs e) RefreshList(); private void CreateProcess_Click(object sender, EventArgs e) DialogBox dlg = new DialogBox(); if (dlg.ShowDialog() = DialogResult.OK) try Process.Start(dlg.FileName); catch (System.ComponentModel.Win32Exception) MessageBox.Show(String.Format(cant find the files 0,please make sure of the name of files then try again。n press start to search files,dlg.FileName); Form1.Designer.csnamespace WindowsApplication1 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() this.listProcesses = new System.Windows.Forms.ListView(); this.StopProcess = new System.Windows.Forms.Button(); this.btnRefresh = new System.Windows.Forms.Button(); this.CreateProcess = new System.Windows.Forms.Button(); this.SuspendLayout(); / / listProcesses / this.listProcesses.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.listProcesses.Location = new System.Drawing.Point(-1, 10); this.listProcesses.Name = listProcesses; this.listProcesses.ShowItemToolTips = true; this.listProcesses.Size = new System.Drawing.Size(363, 297); this.listProcesses.TabIndex = 0; this.listProcesses.UseCompatibleStateImageBehavior = false; / / StopProcess / this.StopProcess.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); this.StopProcess.Location = new System.Drawing.Point(274, 313); this.StopProcess.Name = StopProcess; this.StopProcess.Size = new System.Drawing.Size(100, 23); this.StopProcess.TabIndex = 1; this.StopProcess.Text = StopProcess; this.StopProcess.UseVisualStyleBackColor = true; this.StopProcess.Click += new System.EventHandler(this.StopProcess_Click); / / btnRefresh / this.btnRefresh.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left); this.btnRefresh.Location = new System.Drawing.Point(12, 313); this.btnRefresh.Name = btnRefresh; this.btnRefresh.Size = new System.Drawing.Size(75, 23); this.btnRefresh.TabIndex = 2; this.btnRefresh.Text = Reflesh(&R); this.btnRefresh.UseVisualStyleBackColor = true; this.btnRefresh.Click += new System.EventHandler(this.Refresh_Click); / / CreateProcess / this.CreateProcess.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.CreateProcess.Location = new System.Drawing.Point(141, 313); this.CreateProcess.Name = CreateProcess; this.CreateProcess.Size = new System.Drawing.Size(100, 23); this.CreateProcess.TabIndex = 3; this.CreateProcess.Text = CreateProcess; this.CreateProcess.UseVisualStyleBackColor = true; this.CreateProcess.Click += new System.EventHandler(this.CreateProcess_Click); / / Form1 / this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(364, 344); this.Controls.Add(this.CreateProcess); this.Controls.Add(this.btnRefresh); this.Controls.Add(this.StopProcess); this.Controls.Add(this.listProcesses); this.Name = Form1; this.Text = Process Manager; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); #endregion private System.Windows.Forms.ListView listProcesses; private System.Windows.Forms.Button StopProcess; private System.Windows.Forms.Button btnRefresh; private System.Windows.Forms.Button CreateProcess; DialogBox.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1 public partial class DialogBox : Form public DialogBox() InitializeComponent(); StartPosition = FormStartPosition.CenterParent; this.label1.Text = open file.; private void DialogBox_Load(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e) DialogResult = DialogResult.OK; private void Cancel_Click(object sender, EventArgs e) DialogResult = DialogResult.Cancel; private void btnShow_Click(object sender, EventArgs e) OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = program|*.exe| + all files|*.*; if (dlg.ShowDialog() = DialogResult.OK) boBox1.Text = dlg.FileName; public string FileName get return boBox1.Text; DialogBox.Designer.csnamespace WindowsApplication1 partial class DialogBox / / 必需的设计器变量。 / 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() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DialogBox); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); boBox1 = new System.Windows.Forms.ComboBox(); this.OK = new System.Windows.Forms.Button(); this.Cancel = new System.Windows.Forms.Button(); this.btnShow = new System.Windows.Forms.Button(); (System.ComponentModel.ISupportInitialize)(this.pictureBox1).BeginInit(); this.SuspendLayout(); / / pictureBox1 / this.pictureBox1.Image = (System.Drawing.Image)(resources.GetObject(pictureBox1.Image); this.pictureBox1.Location = new System.Drawing.Point(12, 12); this.pictureBox1.Name = pictureBox1; this.pictureBox1.Size = new System.Drawing.Size(32, 35); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; / / label1 / this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(67, 16); this.label1.Name = label1; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 1; / / label2 / this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(10, 64); this.label2.Name = label2; this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 2; this.label2.Text = Open:; / / comboBox1 / boBox1.FormattingEnabled = true; boBox1.Location = new System.Drawing.Point(69, 61); boBox1.Name = comboBox1; boBox1.Size = new System.Drawing.Size(242, 20); boBox1.TabIndex = 3; / / OK / this.OK.Location = new System.Drawing.Point(74, 98); this.OK.Name = OK; this.OK.Size = new System.Drawing.Size(75, 23); this.OK.TabIndex = 4; this.OK.Text = Enter; this.OK.UseVisualStyleBackColor = true; this.OK.Click += new System.EventHandler(this.OK_Click); / / Cancel / this.Cancel.Location = new System.Drawing.Point(155, 98); this.Cancel.Name = Cancel; this.Cancel.Size = new System.Drawing.Size(75, 23); this.Cancel.TabIndex = 5; this.Cancel.Text = Exit; this.Cancel.UseVisualStyleBackColor = true; this.Cancel.Click += new System.EventHandler(this.Cancel_Click); / / btnShow / this.btnShow.Location = new System.Drawing.Point(236, 98); this.btnShow.Name = btnShow; this.btnShow.Size = new System.Drawing.Size(75, 23); this.btnShow.TabIndex = 6; this.btnShow.Text = Browse.; this.btnShow.UseVisualStyleBackColor = true; this.btnShow.Click += new System.EventHandler(this.btnShow_Click); / / DialogBox / this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(327, 133); this.Controls.Add(this.btnShow); this.Controls.Add(this.Cancel); this.Controls.Add(this.OK); this.Controls.Add(boBox1); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Cont
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 网络招聘信息管理办法
- 税务稽查门店管理办法
- 纽约公寓出租管理办法
- 电子公文盖章管理办法
- 2025政治理论时政热点知识试题库(含答案)
- 软件外包创新-洞察及研究
- 北京市密云区2024-2025学年八年级下学期期末道德与法治试题(含答案)
- 出差安全培训课件
- 2025房屋租赁合同(大产权)
- 2025家居采购合同
- 市场管理考试试题及答案
- 砍树 栽树劳务合同范本
- 社区网格员笔试考试题库及参考答案
- 2025年中小学生科学知识竞赛试题及答案
- 避免车祸安全知识培训课件
- 胸腰椎压缩骨折课件
- 音乐课简谱教学课件
- 2025年放射工作人员培训考试试题及答案
- 2025-2026学年统编版(2024)小学语文一年级上册教学计划及进度表
- 中小学教师中高级职称答辩备考试题及答案(50题)
- 剖析我国公立医院管理体制:问题洞察与改革路径探究
评论
0/150
提交评论