AliDDNS/net.nutcore.aliddns/net.nutcore.aliddns/Program.cs
2021-01-13 14:45:43 +08:00

38 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace net.nutcore.aliddns
{
static class Program
{
//static bool checkUpdate; //用于检测是否自动升级
static System.Threading.Mutex _mutex; //定义为类变量,而非局部变量,用于检测线程
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
//设定是否可以打开新进程的判断参数
bool isNew;
//获取程序集Guid作为唯一标识
Attribute guid_attr = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(GuidAttribute));
string guid = ((GuidAttribute)guid_attr).Value; //此时guid对当前登录用户生效当声明为Global时对所有用户有效
_mutex = new System.Threading.Mutex(true, guid, out isNew);
if ( isNew ) //没有重复进程时
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form_main());
}
else
{
MessageBox.Show("本程序已经在运行中!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
//_mutex.ReleaseMutex();
}
}
}