How to cut out some context menu options with shell extension based on IExecuteCommand?

When implementing the context menu shell extension using the IExecuteCommand approach (as described in this blog post ), how can this menu option be grayed out?

eg. Suppose a shell extension offers some menu options, and some of them should be grayed out based on some state and conditions that calculate the shell extension, for example: if the user right-clicks on a file, and the shell extension detects that this file has some specified properties, some parameters of the shell extension context menu should be grayed out.

How to do it using IExecuteCommand ?

Or should a different Windows Shell COM interface be used for this?

+1
c ++ windows shell winapi contextmenu
source share
1 answer

I have never tried this, but you should be able to set the CommandStateHandler (undocumented?) In your verb key in the CLSID that implements IExplorerCommandState .

You might also consider implementing IExplorerCommand instead of IExecuteCommand + IExplorerCommandState ...

You can also hide verbs based on a request to the property system with a value of AppliesTo .

+2
source share

All Articles