mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use new api for program plugin
This commit is contained in:
parent
a0ebe2916f
commit
3ed8af8c6c
2 changed files with 4 additions and 23 deletions
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
|
@ -33,8 +32,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
|
||||
internal static PluginInitContext Context { get; private set; }
|
||||
|
||||
internal static bool IsAdmin = IsAdministrator();
|
||||
|
||||
private static readonly List<Result> emptyResults = new();
|
||||
|
||||
private static readonly MemoryCacheOptions cacheOptions = new() { SizeLimit = 1560 };
|
||||
|
|
@ -462,12 +459,5 @@ namespace Flow.Launcher.Plugin.Program
|
|||
{
|
||||
Win32.Dispose();
|
||||
}
|
||||
|
||||
private static bool IsAdministrator()
|
||||
{
|
||||
using var identity = WindowsIdentity.GetCurrent();
|
||||
var principal = new WindowsPrincipal(identity);
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Security;
|
|||
using System.Text;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Flow.Launcher.Plugin.Program.Logger;
|
||||
using Flow.Launcher.Plugin.Program.Views.Models;
|
||||
|
|
@ -206,18 +205,10 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
return result;
|
||||
}
|
||||
|
||||
private void Launch(bool elevated = false)
|
||||
private void Launch(bool runAsAdmin = false)
|
||||
{
|
||||
if (Main.IsAdmin && elevated)
|
||||
{
|
||||
// Since we are already elevated, we need to create UAC dialog manually
|
||||
if (Main.Context.API.ShowUACDialog(Name, IcoPath, LnkResolvedPath) != MessageBoxResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_ = Task.Run(() => Main.Context.API.StartProcess(LnkResolvedPath, runAsAdmin:elevated)).ConfigureAwait(false);
|
||||
_ = Task.Run(() => Main.Context.API.StartProcess(
|
||||
FullPath, ParentDirectory, string.Empty, true, runAsAdmin ? "runas" : ""));
|
||||
}
|
||||
|
||||
public List<Result> ContextMenus(IPublicAPI api)
|
||||
|
|
@ -234,7 +225,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
FileName = FullPath, WorkingDirectory = ParentDirectory, UseShellExecute = true
|
||||
};
|
||||
|
||||
_ = Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info)).ConfigureAwait(false);
|
||||
_ = Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info));
|
||||
|
||||
return true;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue