Add administrator mode check

This commit is contained in:
Jack251970 2025-05-22 18:43:41 +08:00
parent 087a45c664
commit 7549bba293

View file

@ -5,6 +5,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@ -753,5 +754,16 @@ namespace Flow.Launcher.Infrastructure
}
#endregion
#region Administrator Mode
public static bool IsAdministrator()
{
using var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
#endregion
}
}