|
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; |
| 4 | +using Vanara.PInvoke; |
7 | 5 |
|
8 | 6 | namespace Files.App.Actions
|
9 | 7 | {
|
@@ -35,36 +33,14 @@ public OpenClassicPropertiesAction()
|
35 | 33 | context.PropertyChanged += Context_PropertyChanged;
|
36 | 34 | }
|
37 | 35 |
|
38 |
| - public Task ExecuteAsync(object? parameter = null) |
| 36 | + public async Task ExecuteAsync(object? parameter = null) |
39 | 37 | {
|
40 |
| - if (context.HasSelection && context.SelectedItems is not null) |
41 |
| - { |
42 |
| - foreach (var item in context.SelectedItems) |
43 |
| - ExecuteShellCommand(item.ItemPath); |
44 |
| - } |
45 |
| - else if (context?.Folder?.ItemPath is not null) |
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; |
| 38 | + var itemPaths = context.HasSelection && context.SelectedItems is not null |
| 39 | + ? context.SelectedItems.Select(x => x.ItemPath).ToArray() |
| 40 | + : new[] { context.Folder!.ItemPath }; |
66 | 41 |
|
67 |
| - PInvoke.ShellExecuteEx(ref info); |
| 42 | + if (itemPaths.Length > 0) |
| 43 | + await ContextMenu.InvokeVerb("properties", itemPaths); |
68 | 44 | }
|
69 | 45 |
|
70 | 46 | private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
0 commit comments