Add IsAdmin

This commit is contained in:
Jack251970 2025-06-12 16:16:58 +08:00
parent a3212affd7
commit 8b8fcd8c7b

View file

@ -47,6 +47,8 @@ namespace Flow.Launcher.Plugin.Shell
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\WindowsApps\wt.exe"),
};
private static readonly bool IsAdmin = IsAdministrator();
private Settings _settings;
public List<Result> Query(Query query)
@ -518,5 +520,12 @@ namespace Flow.Launcher.Plugin.Shell
{
Context.API.RemoveGlobalKeyboardCallback(API_GlobalKeyboardEvent);
}
private static bool IsAdministrator()
{
using var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
}