- using System.Security.Principal;
- namespace Y.Utils.ComputerUtils
- {
- public class ComputerPermissionTool
- {
- public static bool IsAdministrator()
- {
- WindowsIdentity identity = WindowsIdentity.GetCurrent();
- WindowsPrincipal principal = new WindowsPrincipal(identity);
- return principal.IsInRole(WindowsBuiltInRole.Administrator);
- }
- }
- }
|