添加项目文件。
This commit is contained in:
60
EleBox.App/Program.cs
Normal file
60
EleBox.App/Program.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DynStatDisk.App
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
//日志的实例化
|
||||
private static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static bool IsActive { get; private set; }
|
||||
|
||||
public static DateTime StartTime = DateTime.Now;
|
||||
|
||||
public static string SystemName = "";
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
bool isAppRunning = false;
|
||||
Mutex mutex = new Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out isAppRunning);
|
||||
if (!isAppRunning)
|
||||
{
|
||||
MessageBox.Show("程序已运行,不能再次打开!");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
// 授权
|
||||
if (!HslCommunication.Authorization.SetAuthorizationCode("12a99167-05ff-4c89-936f-93d42033f882"))
|
||||
{
|
||||
//active failed
|
||||
MessageBox.Show("授权失败!当前程序只能使用8小时!");
|
||||
// return;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Main());
|
||||
}
|
||||
|
||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Exception ex = e.ExceptionObject as Exception;
|
||||
logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user