标题:[讨论]怎么修改当前程序实例?
取消只看楼主
amingo
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2004-8-27
 问题点数:0 回复次数:1 
[讨论]怎么修改当前程序实例?

using System.Diagnostics;

using System.Reflection;

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;

}

系统Main函数
if( RunningInstance() == null )

Application.Run(new yourFormName());

我用上面这种方法让程序只能产生一个实例,
我想做的是:如果程序已经运行,把它弹出并显示到最前面。

怎么实现 望高手指点!

搜索更多相关主题的帖子: Process 实例 processes using 
2006-04-04 22:17
amingo
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2004-8-27
得分:0 
这个群的人水平很有限啊!
2006-04-04 22:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-55135-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.683032 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved