Improve code quality

This commit is contained in:
Jack251970 2025-06-15 01:24:07 +08:00
parent e5316a0ac4
commit b6b45d495a
6 changed files with 19 additions and 7 deletions

View file

@ -588,7 +588,7 @@ namespace Flow.Launcher.Plugin
public Task<long> StopwatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
/// <summary>
/// Start a process with the given file path and arguments
/// Start a process with support for handling administrative privileges
/// </summary>
/// <remarks>
/// It can help to start a de-elevated process and show user account control dialog when Flow is running as administrator.
@ -602,7 +602,7 @@ namespace Flow.Launcher.Plugin
public bool StartProcess(string filePath, string workingDirectory = "", string arguments = "", bool useShellExecute = false, string verb = "");
/// <summary>
/// Start a process with the given file path and arguments
/// Start a process with support for handling administrative privileges
/// </summary>
/// <remarks>
/// It can help to start a de-elevated process and show user account control dialog when Flow is running as administrator.

View file

@ -437,7 +437,7 @@ namespace Flow.Launcher
}
else
{
StartProcess(uri.AbsoluteUri, arguments: null, useShellExecute: true);
StartProcess(uri.AbsoluteUri, arguments: string.Empty, useShellExecute: true);
}
}

View file

@ -390,7 +390,7 @@ namespace Flow.Launcher.Plugin.Explorer
{
try
{
Main.Context.API.StartProcess(shellPath, workingDirectory: record.FullPath);
Main.Context.API.StartProcess(shellPath, workingDirectory: record.FullPath, arguments: string.Empty);
return true;
}
catch (Exception e)

View file

@ -516,7 +516,10 @@ namespace Flow.Launcher.Plugin.Program.Programs
command = Environment.ExpandEnvironmentVariables(command.Trim());
_ = Task.Run(() => Main.Context.API.StartProcess(
command, string.Empty, string.Empty, true, elevated ? "runas" : ""));
command,
arguments: string.Empty,
useShellExecute: true,
verb: elevated ? "runas" : ""));
}
internal static bool IfAppCanRunElevated(XmlNode appNode)

View file

@ -208,7 +208,11 @@ namespace Flow.Launcher.Plugin.Program.Programs
private void Launch(bool runAsAdmin = false)
{
_ = Task.Run(() => Main.Context.API.StartProcess(
FullPath, ParentDirectory, string.Empty, true, runAsAdmin ? "runas" : ""));
FullPath,
workingDirectory: ParentDirectory,
arguments: string.Empty,
useShellExecute: true,
verb: runAsAdmin ? "runas" : ""));
}
public List<Result> ContextMenus(IPublicAPI api)

View file

@ -309,7 +309,12 @@ namespace Flow.Launcher.Plugin.Shell
private static Process StartProcess(ProcessStartInfo info)
{
Context.API.StartProcess(info.FileName, info.WorkingDirectory, info.ArgumentList, info.UseShellExecute, info.Verb);
Context.API.StartProcess(
info.FileName,
workingDirectory: info.WorkingDirectory,
argumentList: info.ArgumentList,
useShellExecute: info.UseShellExecute,
verb: info.Verb);
return null;
}