参考这个:How do I restrict my application to one instance?
http://www.c-sharpcorner.com/FAQ/Create1InstanceAppSC.asp
http://www.c-sharpcorner.com/FAQ/Create1InstanceAppSC.asp
解决方案 »
- c# 显示ACCESS数据
- devenv编译时如何获得Makefile里面定义的变量
- 急!SQL高手请进:通过查询组合字符串的问题!
- C#中关于目录的操作的方法问题,在线请解答...急急急
- 用arraylist的SyncRoot属性就出异常?c#高人进。。。。。。。。。。。。。。。。。。。。。。。。
- 用ICSharpCode.SharpZipLib的ZipInputStream解压文件报错
- C# 将listview内容写入xml 求范例
- udp通信时服务器所在的PC机上设置了5个ip,udp服务器想绑定本机是否需要将5个IP地址一一绑定?
- 判断DateSet读取数据的问题!
- 如何读取用户在IE中定义的书签?
- 有关.net framework
- 斑竹,给点分给我好吗?
{
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;
}