public static Process RunningInstance()
{
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName (current.ProcessName);
//Loop through the running processes in with the same name
foreach (Process process in processes)
{
//Ignore the current process
if (process.Id != current.Id)
{
//Make sure that the process is running from the exe file.
if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
{
//Return the other process instance.
return process;
}
}
}
//No other instance was found, return null.
return null;
}
{
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName (current.ProcessName);
//Loop through the running processes in with the same name
foreach (Process process in processes)
{
//Ignore the current process
if (process.Id != current.Id)
{
//Make sure that the process is running from the exe file.
if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
{
//Return the other process instance.
return process;
}
}
}
//No other instance was found, return null.
return null;
}
解决方案 »
- c# orcle编程 插入number类型数据
- C#安装出现了问题帮帮忙
- 如何最大限度利用有限的面积,看帖子内容,谢谢
- Form_load事件中设置datagridview的内容但不显示
- 为什么老是报"加载报表失败!!!" ?????
- 求救昂!!字符排列组合的问题!谁能完美的处理各种情况~(200)
- csdn可不可以不发短消息广告给我?
- 在C#中如何调用.dll文件
- 如何 取出网页上的超链接 不使用WebBrows控件????急急急
- 求救,使用c#执行网页js文件,总是提示document未定义
- 如何使DATAGRID在任何情况下都只选中当前行
- MSDN求救,已经安装了好几次,都不都使用,那位前辈总结一下MSDN使用的方法吗?(感激不尽)
static void Main()
{
bool runOne; gM1 = new Mutex(true,"MyNotifyDemo");
runOne=gM1.WaitOne(10,true); if (runOne==false) //已经有一个实例在运行
{
MessageBox.Show("图标已经添加!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
Application.Run(new Form1());
gM1.ReleaseMutex( );
}