日期:2014-05-19  浏览次数:20787 次

c#判断你打开的应用程序是否以打开
c#判断你打开的应用程序是否以打开

------解决方案--------------------
查进程名是否存在。

http://blog.csdn.net/knight94/archive/2006/03/16/625809.aspx
------解决方案--------------------
c#实现程序启动唯一实例的一种方法

private static void GetSingleThread()
{
string name = Process.GetCurrentProcess().ProcessName;
int id = Process.GetCurrentProcess().Id;
Process[] prc = Process.GetProcesses();
foreach(Process pr in prc)
{
if ((name == pr.ProcessName) && (pr.Id != id))
{
MessageBox.Show( "对不起,本地已经有系统正在运行!\n. ", "提示 ",MessageBoxButtons.OK,MessageBoxIcon.Warning);
System.Environment.Exit(0);
}
}

------解决方案--------------------
楼上正解

------解决方案--------------------
Boolean createNew;
Mutex mut=new Mutex(false, ProcessName, createdNew);
if(!createdNew)
{
MessageBox::Show( "Error! ");
Environment::Exit(1);
}

------解决方案--------------------
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName( "Name ");
if(myProcesses.Length > 1)
{
//MessageBox.Show( "已启动 ")
}
else
{
//Form1.ShowDialog();

}