Browse Source

增加 IsAdministratorRole 方法。

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

19
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
/// <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
#region Exception

Loading…
Cancel
Save