void ProcessItem(IService service)
        {
            var input = service.GetInput <ProcessItem>();

            if (input.openWith)
            {
                var p = Process.Start("rundll32.exe", $"shell32, OpenAs_RunDLL {input.file}");
                Api.SetActiveWindow(p.MainWindowHandle);
                Api.SetForegroundWindow(p.MainWindowHandle);
            }
            else if (input.showProperties)
            {
                var info = new Api.SHELLEXECUTEINFO()
                {
                    lpVerb = "properties",
                    lpFile = input.file,
                    nShow  = Api.SW_SHOW,
                    fMask  = Api.SEE_MASK_INVOKEIDLIST
                };
                info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
                Api.ShellExecuteEx(ref info);
                Api.SetActiveWindow(info.hwnd);
                Api.SetForegroundWindow(info.hwnd);
            }
            else
            {
                var p = new Process();
                p.StartInfo.UseShellExecute = true;
                p.StartInfo.ErrorDialog     = true;
                p.StartInfo.FileName        = input.file;
                p.Start();
            }

            service.SendResult(new object());
        }
Exemple #2
0
 public static extern bool ShellExecuteEx(ref Api.SHELLEXECUTEINFO lpExecInfo);