首页 > 编程技术 > csharp

C#判断当前程序是否通过管理员运行的方法

发布时间:2020-6-25 11:33

本文实例讲述了C#判断当前程序是否通过管理员运行的方法。分享给大家供大家参考。

具体实现代码如下:

复制代码 代码如下:

public bool IsAdministrator()
{
WindowsIdentity current = WindowsIdentity.GetCurrent();
WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current);
return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
}

希望本文所述对大家的C#程序设计有所帮助。

标签:[!--infotagslink--]

您可能感兴趣的文章: