博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#源码 批量结束进程 让系统加速 参数配置保存
阅读量:2389 次
发布时间:2019-05-10

本文共 3467 字,大约阅读时间需要 11 分钟。

批量结束进程 让系统加速

运行环境:Win10,其它版本的windows系统需安装.net framework 4.0

1.双击当前进程,会加入到要结束的进程列表里

using 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;namespace KillProcess{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }         ///         /// 关闭进程名含某某的进程 数组        ///         /// 进程名数组        private static void KillProcess(string[] processName)        {            Process[] myproc = Process.GetProcesses();            foreach (Process item in myproc)            {                foreach (string pn in processName)                {                    if (pn.Length < 1)                    {                        break;                    }                    if (item.ProcessName.Contains(pn))                    {                        item.Kill();                    }                }            }        }        ///         /// 关闭进程名含某某的进程        ///         /// 进程名        private static void KillProcess(string processName)        {            Process[] myproc = Process.GetProcesses();            foreach (Process item in myproc)            {                if (item.ProcessName.Contains(processName))                {                    item.Kill();                }            }        }        //强制关闭最近打开的某个进程        private static void KillRecentProcess(string processName)        {            System.Diagnostics.Process[] Proc = System.Diagnostics.Process.GetProcessesByName(processName);            System.DateTime startTime = new DateTime();            int m, killId = 0;            for (m = 0; m < Proc.Length; m++)            {                if (startTime < Proc[m].StartTime)                {                    startTime = Proc[m].StartTime;                    killId = m;                }            }            if (Proc[killId].HasExited == false)            {                Proc[killId].Kill();            }        }        private void DisplayProcess()        {            listBox1.Items.Clear();            Process[] myproc = Process.GetProcesses();            foreach (Process item in myproc)            {                listBox1.Items.Add(item.ProcessName);            }            listBox1.Sorted = true;            label1.Text = "当前系统进程:" + listBox1.Items.Count;        }        private void Form1_Load(object sender, EventArgs e)        {            DisplayProcess();            KillProcess(Settings1.Default.kill.Split(','));            textBox1.Text = Settings1.Default.kill;        }        private void Form1_FormClosing(object sender, FormClosingEventArgs e)        {             Settings1.Default.kill=textBox1.Text;             Settings1.Default.Save();        }        private void listBox1_DoubleClick(object sender, EventArgs e)        {            string str = ((ListBox)sender).SelectedItem.ToString();            ((ListBox)sender).Items.Remove(((ListBox)sender).SelectedItem);            label1.Text = "当前系统进程:" + listBox1.Items.Count;            KillProcess(str);            //DisplayProcess();            if (textBox1.Text == "")            {                textBox1.Text = str;            }            else            {                textBox1.Text += "," + str;            }                   }        private void label1_Click(object sender, EventArgs e)        {            DisplayProcess();        }    }}

你可能感兴趣的文章
nginx dos
查看>>
RASP解决方案包括开源方案
查看>>
Linux下共享文件系统文件传输的简单设计(转载)
查看>>
点评Ubuntu下的文件安全删除工具
查看>>
数据可视化
查看>>
Security Ressources Sites
查看>>
mysql的比较运算
查看>>
Data Breach Report
查看>>
再探偏移注射
查看>>
DNS Security Tips
查看>>
符号执行
查看>>
Remote Installation Service (RIS) in Windows Server 2003
查看>>
Layer Four Traceroute
查看>>
Hardening guide for Apache 2.2.15 on RedHat 5.4 (64bit edition)
查看>>
Microsoft Outlook Web Access (OWA) version 8.2.254.0 information disclosure vulnerability
查看>>
STP mitm attack idea
查看>>
Month of PHP Security - Summary
查看>>
近期将要购买的图书
查看>>
nginx Directory Traversal Vulnerability
查看>>
Linux下apache+svn+ssl完美结合搭建安全版本控制平台
查看>>