ComputerPermissionTool.cs 521 B

12345678910111213141516171819
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Principal;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Y.Utils.ComputerUtils
  8. {
  9. public class ComputerPermissionTool
  10. {
  11. public static bool IsAdministrator()
  12. {
  13. WindowsIdentity identity = WindowsIdentity.GetCurrent();
  14. WindowsPrincipal principal = new WindowsPrincipal(identity);
  15. return principal.IsInRole(WindowsBuiltInRole.Administrator);
  16. }
  17. }
  18. }