-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (35 loc) · 1.24 KB
/
Program.cs
File metadata and controls
39 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Windows.Forms;
namespace handsoff
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (!IsAdministrator())
{
MessageBox.Show(Application.ProductName + " requires elevated privileges to work properly.\nPlease run it as administrator.", "Elevated privileges required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Environment.Exit(0);
}
LeanDeploy.BeforeUninstall += App.OnUninstall;
LeanDeploy.ProcessesKilled += App.OnProcessesKilled;
LeanDeploy.Check();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new App());
}
public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
}