|
1 | 1 | // Copyright (c) 2024 Files Community
|
2 | 2 | // Licensed under the MIT License. See the LICENSE.
|
3 | 3 |
|
| 4 | +using System.Runtime.InteropServices; |
| 5 | +using Windows.Win32; |
| 6 | +using Windows.Win32.UI.Shell; |
| 7 | + |
4 | 8 | namespace Files.App.Actions
|
5 | 9 | {
|
6 | 10 | internal sealed class OpenClassicPropertiesAction : ObservableObject, IAction
|
@@ -31,12 +35,36 @@ public OpenClassicPropertiesAction()
|
31 | 35 | context.PropertyChanged += Context_PropertyChanged;
|
32 | 36 | }
|
33 | 37 |
|
34 |
| - public async Task ExecuteAsync(object? parameter = null) |
| 38 | + public Task ExecuteAsync(object? parameter = null) |
35 | 39 | {
|
36 | 40 | if (context.HasSelection && context.SelectedItems is not null)
|
37 |
| - await ContextMenu.InvokeVerb("properties", context.SelectedItems.Select(x => x.ItemPath).ToArray()); |
| 41 | + { |
| 42 | + foreach (var item in context.SelectedItems) |
| 43 | + ExecuteShellCommand(item.ItemPath); |
| 44 | + } |
38 | 45 | else if (context?.Folder?.ItemPath is not null)
|
39 |
| - await ContextMenu.InvokeVerb("properties", context.Folder.ItemPath); |
| 46 | + { |
| 47 | + ExecuteShellCommand(context.Folder.ItemPath); |
| 48 | + } |
| 49 | + |
| 50 | + return Task.CompletedTask; |
| 51 | + } |
| 52 | + |
| 53 | + private unsafe void ExecuteShellCommand(string itemPath) |
| 54 | + { |
| 55 | + SHELLEXECUTEINFOW info = default; |
| 56 | + info.cbSize = (uint)Marshal.SizeOf(info); |
| 57 | + info.nShow = 5; // SW_SHOW |
| 58 | + info.fMask = 0x0000000C; |
| 59 | + |
| 60 | + var verb = "properties"; |
| 61 | + fixed (char* cVerb = verb) |
| 62 | + info.lpVerb = cVerb; |
| 63 | + |
| 64 | + fixed (char* lpFile = itemPath) |
| 65 | + info.lpFile = lpFile; |
| 66 | + |
| 67 | + PInvoke.ShellExecuteEx(ref info); |
40 | 68 | }
|
41 | 69 |
|
42 | 70 | private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
0 commit comments