软件编程
位置:首页>> 软件编程>> C#编程>> C#判断当前程序是否通过管理员运行的方法

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

作者:shichen2014  发布时间:2023-09-27 15:48:24 

标签:C#,判断,管理员

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

具体实现代码如下:


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

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

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com