C# 避免程序重复启动

2021-01-26 03:13

阅读:445

标签:name   collect   message   point   app   stack   bool   span   render   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// 
        /// The main entry point for the application.
        /// 
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool ret;
            Mutex mutex = new Mutex(true, Application.ProductName, out   ret);
            if (ret)
            {
                Application.Run(new Form1());
            }
            else
            {
                MessageBox.Show("该程序已经启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            
        }
    }
}

转自https://www.cnblogs.com/LicwStack/p/8587352.html

C# 避免程序重复启动

标签:name   collect   message   point   app   stack   bool   span   render   

原文地址:https://www.cnblogs.com/WeiYongZhi/p/12001150.html


评论


亲,登录后才可以留言!