[C#]判断当前进程/线程是否运行在管理员身份下

C#里判断当前进程/线程是否运行在管理员身份下

WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
bool isRunningElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);

Leave a Reply

Your email address will not be published. Required fields are marked *