Browse Source

增加 IsAdministratorRole 方法。

master
王厅 7 days ago
parent
commit
03bf5387a7
  1. 19
      Apewer/RuntimeUtility.cs

19
Apewer/RuntimeUtility.cs

@ -1,14 +1,15 @@
using Apewer.Internals; using Apewer.Internals;
using Apewer.Models; using Apewer.Models;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading;
using System.Collections;
using System.Text; using System.Text;
using System.Threading;
using static System.Net.Mime.MediaTypeNames;
namespace Apewer namespace Apewer
{ {
@ -1035,6 +1036,20 @@ namespace Apewer
#endif #endif
} }
#if NETFRAMEWORK
/// <summary>当前进程是以管理员身份运行。</summary>
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 #endregion
#region Exception #region Exception

Loading…
Cancel
Save