-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
27 lines (23 loc) · 834 Bytes
/
Program.cs
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
using System;
using System.Windows.Forms;
namespace HostsManager
{
public static class Program
{
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (WindowsSecurity.NeedsAdministratorRights() && !WindowsSecurity.HasAdministratorRights())
{
if (!WindowsSecurity.RunElevated())
{
MessageBox.Show("I do not have permission to write to the HOSTS file right now.\n\nPlease run this application as an Administrator.", "Windows Security", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
Environment.Exit(0);
}
Application.Run(new MainForm());
}
}
}