From b6b45d495a2c7d73752ef6e8494f8a23666b1f1c Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 15 Jun 2025 01:24:07 +0800 Subject: [PATCH] Improve code quality --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 4 ++-- Flow.Launcher/PublicAPIInstance.cs | 2 +- Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs | 2 +- .../Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs | 5 ++++- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 6 +++++- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 7 ++++++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 2f07b6868..d5efa3c1e 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -588,7 +588,7 @@ namespace Flow.Launcher.Plugin public Task StopwatchLogInfoAsync(string className, string message, Func action, [CallerMemberName] string methodName = ""); /// - /// Start a process with the given file path and arguments + /// Start a process with support for handling administrative privileges /// /// /// 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 = ""); /// - /// Start a process with the given file path and arguments + /// Start a process with support for handling administrative privileges /// /// /// It can help to start a de-elevated process and show user account control dialog when Flow is running as administrator. diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index bdf719c72..acfbe9d76 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -437,7 +437,7 @@ namespace Flow.Launcher } else { - StartProcess(uri.AbsoluteUri, arguments: null, useShellExecute: true); + StartProcess(uri.AbsoluteUri, arguments: string.Empty, useShellExecute: true); } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 0fa5fd562..c83f74b5b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -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) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs index 646079946..abd08e181 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs @@ -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) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 3a443df50..4034f8d7f 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -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 ContextMenus(IPublicAPI api) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index 715b74bbe..8b402f930 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -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; }