diff --git a/Form1.cs b/Form1.cs index 2c9b5be..2864109 100644 --- a/Form1.cs +++ b/Form1.cs @@ -24,7 +24,7 @@ public partial class Form1 : Form private Int16 ModeSlow = 5000; private Int16 ModeNormarl = 3000; private Int16 ModeFast = 1000; - private string VERSION = "v0.8.26"; + private string VERSION = "v0.8.27"; private string GITHUB = "https://github.com/Fhwang0926/CoreTracker"; private bool mouseDown; @@ -549,5 +549,6 @@ private bool toggleTraySetting() + diff --git a/Lib/Program.cs b/Lib/Program.cs index 73521f0..060b026 100644 --- a/Lib/Program.cs +++ b/Lib/Program.cs @@ -1,12 +1,20 @@ using System; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Security.Principal; using System.Windows.Forms; namespace CoreTracker { static class Program { + public static bool IsAdministrator() + { + WindowsIdentity identity = WindowsIdentity.GetCurrent(); + WindowsPrincipal principal = new WindowsPrincipal(identity); + return principal.IsInRole(WindowsBuiltInRole.Administrator); + } /// /// 해당 애플리케이션의 주 진입점입니다. /// @@ -15,6 +23,18 @@ static void Main(string[] args) { try { + if (!Program.IsAdministrator()) + { + // Restart and run as admin + var exeName = Process.GetCurrentProcess().MainModule.FileName; + ProcessStartInfo startInfo = new ProcessStartInfo(exeName); + startInfo.Verb = "runas"; + startInfo.Arguments = "restart"; + Process.Start(startInfo); + Application.Exit(); + return; + } + // real start System.Threading.Mutex mutex = new System.Threading.Mutex(false, System.Diagnostics.Process.GetCurrentProcess().ProcessName); try {