Recent

Author Topic: IExplorerCommand shell extension  (Read 3632 times)

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
IExplorerCommand shell extension
« on: December 22, 2023, 09:56:07 pm »
Hi all,

With Windows 11, Microsoft implemented changes regarding extending context menus. In fact, old shell extensions based on IContextMenu are now legacy and no more displayed in the context menu's root, but in a 'Show more options' sub-menu.

New shell extensions should be build with IExplorerCommand but no examples can be found.

Can anybody provide some insightful information ?

Many thanks !

d7_2_laz

  • Hero Member
  • *****
  • Posts: 547
Re: IExplorerCommand shell extension
« Reply #1 on: December 31, 2023, 02:50:27 pm »
@rpetges, you asked this, meanwhile, twice and had none responses yet at all, but i don’t wonder why. Net researches for IExplorerCommand and Delphi etc. won’t return any results that might be applicable to preserve the existing system context menu behavior on Win11 without major efforts. The MS api documentation here is - said politely - not  very helpful. This is a pity.

The main challenge – imo – would be to keep an app’s context menu ie. for files and folders objects like it is on Win10’s IContextMenu when running Win11. Actually it appears to stay alive within a sub-menu. That’s why I’m myself very interested in this topic because the tools I wrote as my daily working horses I’d expect to behave just as before.

My personal conclusion is: if i once need to buy a new workstation (but i don’t want to do this - mine is really fast enough but cannot upgrade due to missing bios TPM), then I’d apply the – meanwhile wellknown – workaround to preserve the “classic”  (“legacy”) Win10 context menu using a registry tweak.
Eg:: https://winaero.com/how-to-enable-full-context-menus-in-windows-11/amp/

In fact, this is a bad necessity of course. As long as no better method is in sight.
Lazarus 3.6  FPC 3.2.2 Win10 64bit

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
Re: IExplorerCommand shell extension
« Reply #2 on: December 31, 2023, 06:16:27 pm »
I searched a lot for IExplorerCommand and Delphi and there is nothing. Even the API definitions don't exist for Delphi or FreePascal/Lazarus.

I know that the legacy shell extensions with IContextMenu can still be used with the "Show More" options or through a registry key. To be honest, none of my customers seem to use the new Win11 context menu as I did not get a single request to implement the new context menu.

However, since Windows 11 I have an issue with the IContextMenu as it's impossible ( at least for my extension ) to be used with a selection of more than 17 items. For more than 17 items, the context menu item from my shell extension does not show anymore. The same shell extension works fine in Windows 10 when I select hundreds of files/folders.

I tried the shell extension skeleton from Marco Cantu and it has the same problem.

Could you please test your shell extension in Windows 11 and select more than 17 items ? Does the context menu entry show up ?

Best regards
« Last Edit: December 31, 2023, 06:19:01 pm by rpetges »

d7_2_laz

  • Hero Member
  • *****
  • Posts: 547
Re: IExplorerCommand shell extension
« Reply #3 on: December 31, 2023, 07:53:46 pm »
As of now  i’m solely still on Win10 and unfortunately cannot test with Win11 yet;  I’m simply motivated by the question: what will happen in future.

My coding (Win10) was following a proposal from ASerge, see this link, there are test projects within: https://forum.lazarus.freepascal.org/index.php/topic,53996.msg400431.html#msg400431

Windows 11 has an issue with the IContextMenu regarding a limited number of selected items … that sounds even worse  :o
You saw that when trying within "Show More", or same when using the reg tweak mentioned?

I’m wondering what others will do (Explorer++, Notepad++ explorer plugin(s), Double commander et.al.), but when I look into I still see the “classic” IContextMenu here. How does Double Commander behave on Win11?
Lazarus 3.6  FPC 3.2.2 Win10 64bit

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
Re: IExplorerCommand shell extension
« Reply #4 on: January 01, 2024, 12:58:27 pm »
It seems to be something related with the new Explorer in Windows 11.

My shell extension works fine in Double Commander on Windows 11, I can select hundreds of files and the "classic Windows" context menu is correctly called. Same for Notepad++.

Maybe it's related to the tab bar feature in Explorer ... don't know however if there is a way to disable it for testing.

WayneSherman

  • Sr. Member
  • ****
  • Posts: 250
Re: IExplorerCommand shell extension
« Reply #5 on: January 22, 2024, 08:56:25 pm »
With Windows 11, Microsoft implemented changes regarding extending context menus. In fact, old shell extensions based on IContextMenu are now legacy and no more displayed in the context menu's root, but in a 'Show more options' sub-menu.
New shell extensions should be build with IExplorerCommand but no examples can be found.

Translation of IExplorerCommand from (older?) ShObjIdl.h
https://github.com/CMCHTPC/WindowsAPI/blob/master/Units/Win32.ShObjIdl.pas#L4220

MS Docs (IExplorerCommand is apparently defined in Shobjidl_core.h now)
https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iexplorercommand

Examples of use:
https://www.google.com/search?q=IExplorerCommand+examples
https://www.google.com/search?q=IExplorerCommand+examples+windows+11

jcmontherock

  • Sr. Member
  • ****
  • Posts: 272
Re: IExplorerCommand shell extension
« Reply #6 on: January 22, 2024, 09:47:09 pm »
Find an example which works with W11/64...
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

d7_2_laz

  • Hero Member
  • *****
  • Posts: 547
Re: IExplorerCommand shell extension
« Reply #7 on: January 23, 2024, 02:19:36 pm »
@jcmontherock, as one who don't has Win11 yet but would like to be prepared, i appreciate your sample a lot!

Anyhow, hm, i'm wondering as i don't recognize - regarding the essentials - much differences between this approach
and the code sample from ASerge (Win resp. Win10) as mentioned via link earlier (reply #3 here).
https://forum.lazarus.freepascal.org/index.php/topic,53996.msg400431.html#msg400431
Eg. both are using IID_IContextMenu, IContextMenu(2,3).  - See uSysContextMenu.zip within this link.

For to shorten this up: if you say your sample works in Win11 like in Win10, this sounds very good!

Moreover, i'd be intereted to see where user defined functions added to the menu (via AppendMenu) will appear (is this what had been called "shell extensions" earlier?? Not sure).
Will it appear within the main popup, or will it be sunken within "More ..." ?
Could you or anybody other interested could attach an image how that will look when generated on Win11?
One might use this little modification of your test project attached.
Lazarus 3.6  FPC 3.2.2 Win10 64bit

jcmontherock

  • Sr. Member
  • ****
  • Posts: 272
Re: IExplorerCommand shell extension
« Reply #8 on: January 23, 2024, 03:32:11 pm »
I do not have Win10. So I can't test it.

Yes, your example works fine.
« Last Edit: January 23, 2024, 03:37:21 pm by jcmontherock »
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

d7_2_laz

  • Hero Member
  • *****
  • Posts: 547
Re: IExplorerCommand shell extension
« Reply #9 on: January 23, 2024, 03:52:27 pm »
Screenshot (when project compiled & run on Win11) would look similar to mine?? That’s really fine ….  :)
Lazarus 3.6  FPC 3.2.2 Win10 64bit

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
Re: IExplorerCommand shell extension
« Reply #10 on: January 28, 2024, 03:43:15 pm »
With Windows 11, Microsoft implemented changes regarding extending context menus. In fact, old shell extensions based on IContextMenu are now legacy and no more displayed in the context menu's root, but in a 'Show more options' sub-menu.
New shell extensions should be build with IExplorerCommand but no examples can be found.

Translation of IExplorerCommand from (older?) ShObjIdl.h
https://github.com/CMCHTPC/WindowsAPI/blob/master/Units/Win32.ShObjIdl.pas#L4220


Many thanks for the link, this should help to convert the COM object from IContextMenu to IExplorerCommand. Hopefully this will resolve the limitation of selecting max 17 items in Explorer for legacy shell extensions.

rpetges

  • Jr. Member
  • **
  • Posts: 98
    • Attribute Changer Website
Re: IExplorerCommand shell extension
« Reply #11 on: January 28, 2024, 03:46:29 pm »
Screenshot (when project compiled & run on Win11) would look similar to mine?? That’s really fine ….  :)

Yes, screenshot looks exactly the same on Windows 11 as on Windows 10. In fact, it displays all the menu items available in "Show more..." in your demo application.

Jiyahana

  • New Member
  • *
  • Posts: 12
Re: IExplorerCommand shell extension
« Reply #12 on: February 01, 2024, 12:13:15 pm »
Microsoft has shifted to using IExplorerCommand for shell extensions moving away from the old IContextMenu.

 

TinyPortal © 2005-2018