改写main()事件:
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
int 进程数 = 0;
Process[] 进程集 = Process.GetProcesses();
foreach(Process 判断进程 in 进程集)
{
if(判断进程.ProcessName == Process.GetCurrentProcess().ProcessName)
{
进程数 += 1;
}
}
if(进程数 > 1)
{
MessageBox.Show("该系统已经在运行中。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new [本系统的主界面]());
}
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
int 进程数 = 0;
Process[] 进程集 = Process.GetProcesses();
foreach(Process 判断进程 in 进程集)
{
if(判断进程.ProcessName == Process.GetCurrentProcess().ProcessName)
{
进程数 += 1;
}
}
if(进程数 > 1)
{
MessageBox.Show("该系统已经在运行中。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new [本系统的主界面]());
}
}
解决方案 »
- 用命令打开一个文本后,怎么可以保存文本中的不同日期,到一个数组中?
- TextBox 数据绑定 修改数据后要移动到其他行才能保存
- C#socke通讯异常问题
- 请教关于TIMER和BackgroundWorker的问题
- 关于二级用户不能登录的问题,请帮忙
- 哪里有c#的视频教程 《c#程序设计基础》
- 无法创建新的堆栈防护页面
- 请问,如何得到datagrid中某一个cell的对象的句柄?
- 我在webform里面放了一个按钮,现在想单击按钮后让当前浏览器关闭,怎么实现
- 用c#开发高级版本的Notepad++++++
- 谁能提出水晶报表的详细资料——高级应用
- '"+textbox1.text+"'谁能详细说明一下这个表达式的意思?
class Test
{
static void Main(string[] args)
{
bool Open = false;
System.Threading.Mutex mutex=new System.Threading.Mutex(true,"Test",out Open);
if(Open)
{
Console.Write("Running");
}
else
{
Console.Write("Another is Running");
System.Threading.Thread.Sleep(3000);//线程挂起3秒钟
Environment.Exit(1);
}
Console.ReadLine();
}
}