Skip to content

Commit e97964b

Browse files
committed
Get context menu string by id instead of index
1 parent 922cbbe commit e97964b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Helper/ShellContextMenuDisplayHelper.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,6 @@ private static void ProcessMenuWithIcons(IntPtr hMenu, IContextMenu contextMenu,
315315

316316
for (uint i = 0; i < menuCount; i++)
317317
{
318-
var menuText = new StringBuilder(256);
319-
uint result = GetMenuString(hMenu, i, menuText, menuText.Capacity, 0x400);
320-
321-
if (result == 0 || string.IsNullOrWhiteSpace(menuText.ToString()))
322-
{
323-
continue;
324-
}
325-
326-
menuText.Replace("&", "");
327-
328318
var mii = new MENUITEMINFO
329319
{
330320
cbSize = (uint)Marshal.SizeOf(typeof(MENUITEMINFO)),
@@ -333,12 +323,16 @@ private static void ProcessMenuWithIcons(IntPtr hMenu, IContextMenu contextMenu,
333323
};
334324

335325
GetMenuItemInfo(hMenu, i, true, ref mii);
326+
var menuText = new StringBuilder(256);
327+
uint result = GetMenuString(hMenu, mii.wID, menuText, menuText.Capacity, 0);
336328

337-
if ((mii.fType & (uint)MenuItemFtype.Separator) != 0)
329+
if (result == 0 || string.IsNullOrWhiteSpace(menuText.ToString()))
338330
{
339331
continue;
340332
}
341333

334+
menuText.Replace("&", "");
335+
342336
IntPtr hSubMenu = GetSubMenu(hMenu, (int)i);
343337
if (hSubMenu != IntPtr.Zero)
344338
{

0 commit comments

Comments
 (0)