From e97964b95c34cfc05ea49a8b2cfd3581eab4b5c0 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Wed, 12 Jun 2024 17:15:58 +0600 Subject: [PATCH] Get context menu string by id instead of index --- .../Helper/ShellContextMenuDisplayHelper.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/ShellContextMenuDisplayHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/ShellContextMenuDisplayHelper.cs index c1cd1d6ba..1157c5b7f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/ShellContextMenuDisplayHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/ShellContextMenuDisplayHelper.cs @@ -315,16 +315,6 @@ public static class ShellContextMenuDisplayHelper for (uint i = 0; i < menuCount; i++) { - var menuText = new StringBuilder(256); - uint result = GetMenuString(hMenu, i, menuText, menuText.Capacity, 0x400); - - if (result == 0 || string.IsNullOrWhiteSpace(menuText.ToString())) - { - continue; - } - - menuText.Replace("&", ""); - var mii = new MENUITEMINFO { cbSize = (uint)Marshal.SizeOf(typeof(MENUITEMINFO)), @@ -333,12 +323,16 @@ public static class ShellContextMenuDisplayHelper }; GetMenuItemInfo(hMenu, i, true, ref mii); + var menuText = new StringBuilder(256); + uint result = GetMenuString(hMenu, mii.wID, menuText, menuText.Capacity, 0); - if ((mii.fType & (uint)MenuItemFtype.Separator) != 0) + if (result == 0 || string.IsNullOrWhiteSpace(menuText.ToString())) { continue; } + menuText.Replace("&", ""); + IntPtr hSubMenu = GetSubMenu(hMenu, (int)i); if (hSubMenu != IntPtr.Zero) {