diff --git a/Apewer/RuntimeUtility.cs b/Apewer/RuntimeUtility.cs index 70be790..da07d3d 100644 --- a/Apewer/RuntimeUtility.cs +++ b/Apewer/RuntimeUtility.cs @@ -1,14 +1,15 @@ using Apewer.Internals; using Apewer.Models; using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; -using System.Threading; -using System.Collections; using System.Text; +using System.Threading; +using static System.Net.Mime.MediaTypeNames; namespace Apewer { @@ -1035,6 +1036,20 @@ namespace Apewer #endif } +#if NETFRAMEWORK + + /// 当前进程是以管理员身份运行。 + public static bool IsAdministratorRole() + { + var identity = System.Security.Principal.WindowsIdentity.GetCurrent(); + var principal = new System.Security.Principal.WindowsPrincipal(identity); + + var result = principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator); + return result; + } + +#endif + #endregion #region Exception