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

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

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

Comments

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

Leave a Reply