首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

WinForm 只允许打开一个程序

Posted on 2010-05-13 13:37  达奇  阅读(366)  评论(0编辑  收藏  举报
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Dachie
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool createNew;

            System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew);
            if (createNew)
                Application.Run(new login());
        }
    }
}