If run as admin already then open DNS changer directly

This commit is contained in:
Jaex 2015-05-06 19:49:57 +03:00
parent e543eace40
commit 228b8bd9bf
2 changed files with 14 additions and 1 deletions

View file

@ -39,6 +39,7 @@ You should have received a copy of the GNU General Public License
using System.Resources;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
@ -847,5 +848,10 @@ public static string GetAbsolutePath(string path)
return Path.GetFullPath(path);
}
public static bool IsAdministrator()
{
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
}
}
}

View file

@ -645,9 +645,16 @@ public static void OpenMonitorTest()
}
public static void OpenDNSChanger()
{
if (Helpers.IsAdministrator())
{
new DNSChangerForm().Show();
}
else
{
RunShareXAsAdmin("-dnschanger");
}
}
public static void RunShareXAsAdmin(string arguments)
{