Skip to content

Commit e18e6b2

Browse files
committed
Revert "Context menu verb"
This reverts commit 5603808.
1 parent 5603808 commit e18e6b2

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@ WindowsCreateString
120120
WindowsDeleteString
121121
IPreviewHandler
122122
AssocQueryString
123+
ShellExecuteEx

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
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;
7+
48
namespace Files.App.Actions
59
{
610
internal sealed class OpenClassicPropertiesAction : ObservableObject, IAction
@@ -31,12 +35,36 @@ public OpenClassicPropertiesAction()
3135
context.PropertyChanged += Context_PropertyChanged;
3236
}
3337

34-
public async Task ExecuteAsync(object? parameter = null)
38+
public Task ExecuteAsync(object? parameter = null)
3539
{
3640
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+
}
3845
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);
4068
}
4169

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

0 commit comments

Comments
 (0)