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


本文向大家介绍C#判断当前程序是否通过管理员运行的方法,包括了C#判断当前程序是否通过管理员运行的方法的使用技巧和注意事项,需要的朋友参考一下

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

具体实现代码如下:


public bool IsAdministrator()

{

WindowsIdentity current = WindowsIdentity.GetCurrent();

WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current);

return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);

}

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