Skip to content

Commit 05affbc

Browse files
committed
Update OpenClassicPropertiesAction.cs
1 parent e18e6b2 commit 05affbc

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

src/Files.App/Actions/Open/OpenClassicPropertiesAction.cs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using System.Runtime.InteropServices;
5-
using Windows.Win32;
6-
using Windows.Win32.UI.Shell;
4+
using Vanara.PInvoke;
75

86
namespace Files.App.Actions
97
{
@@ -35,36 +33,14 @@ public OpenClassicPropertiesAction()
3533
context.PropertyChanged += Context_PropertyChanged;
3634
}
3735

38-
public Task ExecuteAsync(object? parameter = null)
36+
public async Task ExecuteAsync(object? parameter = null)
3937
{
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 };
6641

67-
PInvoke.ShellExecuteEx(ref info);
42+
if (itemPaths.Length > 0)
43+
await ContextMenu.InvokeVerb("properties", itemPaths);
6844
}
6945

7046
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)

0 commit comments

Comments
 (0)