c#实现同一个实例只能运行一次
using System;
using System.Collections.Generic;
using System.Text;
using IRADManager.Common;
using System.Diagnostics;
using Microsoft.Win32;
using System.IO;
using System.Resources;
using System.Reflection;
using System.Threading;
using System.Globalization;
namespace common
{
public class util
{
///
///方法RunedTest表示:根据当前进程名判断是否存在相同进程,如果存在只能运行一个实例并且返回true,否则返回false.
///
public static bool RunedTest()
{
Process cp = Process.GetCurrentProcess();
Process[] ps = Process.GetProcessesByName(cp.ProcessName);
return ps != null && ps.Length >1;
}
}
}