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;
}
解决方案 »
- 大侠们 求救(超级郁闷)
- 提取访客来源页
- 在asp.net中如何将表单提交到指定的邮箱?
- Panel动态添加控件后的位置问题
- 关于PetShop连接字符串问题?
- 如何让页面不随浏览器大小改变而改变?
- 怎么弹出对话框
- 如何对<%# DataBinder.Eval(Container.DataItem,"回复")%>进行判断?
- 如果把SqlDbType和DbType类型的数据转化为Asp.net自己的类型:System.Type(再线等待)
- [求助]如何从大于255个字符的文本中搜索某个字符串?
- 请帮忙查看该代码,为什么中文会乱码。其中main.txt中有中文字.
- 在windows server 中工程出這樣的錯
{
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;
}