zoukankan      html  css  js  c++  java
  • C#中强制关闭某个进程

            /// <summary>
            /// 关闭进程
            /// </summary>
            /// <param name="processName">进程名</param>
            private void KillProcess(string processName)
            {
                Process[] myproc = Process.GetProcesses();
                foreach (Process item in myproc)
                {
                    if (item.ProcessName == processName)
                    {
                        item.Kill();
                    }
                }

            }


         //强制关闭最近打开的某个进程

         private 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();

             }

         }


  • 相关阅读:
    在unity中内置一个查询物流信息功能
    socket 广播消息
    Socket通信
    用SecureCRT在windows和CentOS间上传下载文件
    Centos6.5下设置静态IP
    oracle 11g dataguard创建的简单方法
    linux下mysql安装、目录结构、配置
    dba诊断之lock
    oracle11G在linux环境下的卸载操作
    Ubuntu 14.04(32位)安装Oracle 11g(32位)全过程
  • 原文地址:https://www.cnblogs.com/kevinGao/p/2236177.html
Copyright © 2011-2022 走看看