代码:

public static Boolean IsAdministrator() {
      System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
      System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
      return principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
}

 

参考:

https://www.bugfine.com/c/c-sharp-check-whether-in-admin/

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-11-19
  • 2022-02-25
猜你喜欢
  • 2021-12-11
  • 2021-10-20
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案