Ejemplo n.º 1
0
 /// <summary>
 /// 结束进程
 /// </summary>
 public static void ProcessExit(string Key)
 {
     foreach (Process ThisProcess in Process.GetProcesses())
     {
         if (ThisProcess.ToString().ToLower().Contains(Key.ToLower()) == true)
         {
             ThisProcess.Kill();
             return;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断进程是否存在
        /// </summary>
        public static bool ProcessExist(string Keys)
        {
            string[] Items = {};
            int      Index = 0;

            Items = Keys.Split(',');

            foreach (Process ThisProcess in Process.GetProcesses())
            {
                for (Index = 0; Index < Items.Length; Index++)
                {
                    if (ThisProcess.ToString().ToLower().Contains(Items[Index].ToLower()) == true)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public void RefreshInfo()
        {
            Name = ThisProcess.ProcessName;
            Info = ThisProcess.ToString();
            Id   = ThisProcess.Id;


            StartInfo = ThisProcess.StartInfo;
            try
            {
                Modules = ThisProcess.Modules;
            }
            catch
            {
                Modules = null;
            }

            try
            {
                if (ThisProcess.MainModule != null)
                {
                    FileName = ThisProcess.MainModule.FileName;
                }
            }
            catch
            {
                FileName = "Access Denied";
            }

            try
            {
                Priority = ThisProcess.PriorityClass.ToString();
            }
            catch
            {
                Priority = "Access Denied";
            }
        }