C# 檢查 Process 是否存在

 
C# 檢查 Process 是否存在
 

   Form1.cs
 
   using System.Diagnostics;
 
   public Boolean ProcessCheck(String ProcessName)
   {
      try
      {
         foreach (Process clsProcess in Process.GetProcesses())
         {
            if (clsProcess.ProcessName.Trim() == ProcessName.Trim())
            {
               return true;
            }
         }
      }
      catch (Exception ex)
      {
         return false;
      }
 
      return false;
   }