21 lines
567 B
C#
21 lines
567 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Principal;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Pulsar.Common.UAC
|
|
{
|
|
public class UAC
|
|
{
|
|
// https://stackoverflow.com/questions/11660184/c-sharp-check-if-run-as-administrator
|
|
public static bool IsAdministrator()
|
|
{
|
|
var identity = WindowsIdentity.GetCurrent();
|
|
var principal = new WindowsPrincipal(identity);
|
|
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
|
}
|
|
}
|
|
}
|