WineMonk / WineMonk.github.io

blog
1 stars 0 forks source link

C#判断程序是否为管理员权限启动 | WineMonk #167

Open WineMonk opened 1 year ago

WineMonk commented 1 year ago

https://shaoshao.net.cn/2023/02/03/202302031640-CSharp%E5%88%A4%E6%96%AD%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E4%B8%BA%E7%AE%A1%E7%90%86%E5%91%98%E6%9D%83%E9%99%90%E5%90%AF%E5%8A%A8/

C# 判断程序是否为管理员权限启动123456bool IsAdministrator(){ WindowsIdentity current = WindowsIdentity.GetCurrent(); WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current); return windowsPr