EZPPClient-Installer/EZPPClient Installer/Utils/ProcessUtil.cs

30 lines
664 B
C#

using System;
using System.Diagnostics;
using System.IO;
namespace EZPPClient_Installer
{
class ProcessUtil
{
public static bool ProgramIsRunning(string FullPath)
{
string FilePath = Path.GetDirectoryName(FullPath);
string FileName = Path.GetFileNameWithoutExtension(FullPath).ToLower();
bool isRunning = false;
Process[] pList = Process.GetProcessesByName(FileName);
foreach (Process p in pList)
{
if (p.MainModule.FileName.StartsWith(FilePath, StringComparison.InvariantCultureIgnoreCase))
{
isRunning = true;
break;
}
}
return isRunning;
}
}
}