110,539
社区成员
发帖
与我相关
我的任务
分享
static void Main()
{
bool createNew;
string name = Process.GetCurrentProcess().ProcessName + "Mutex";
using (Mutex mtx = new Mutex(true, name, out createNew))
{
if (!createNew) return;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
namespace FallingGold
{
static class Program
{
private static Mutex mutex;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mutex = new Mutex(true, "一个");
//保证只有一个实例运行
if (mutex.WaitOne(0, false))
{
Application.Run(new MaimForm());
}
}
}
}
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
if (BI.KillMore())
{
MessageBox.Show(BI.strError);
}
else
{
Application.Run(new Login());
}
public static bool KillMore()
{
int length = System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length;
return length > 1;
}
//没想到刚开始学的一点小东西还有用途
static class Program
{
private static Mutex mutex;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mutex = new Mutex(true, "OnlyRun");
if (mutex.WaitOne(0, false))
{
Application.Run(new Form1());
}
else
{
MessageBox.Show("程序已经运行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
Application.Exit();
}
}
}