改写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 [本系统的主界面]());
            }
}

解决方案 »

  1.   

    System.Threading.Mutex :同步基元,它只向一个线程授予对共享资源的独占访问权.测试代码: 
    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();
        }
    }