How to hide context menu item by using IExplorerCommand

Jojo Tang 86 Reputation points
2020-12-14T01:40:09.217+00:00

I am inherit IExplorerCommand, IInitializeCommand, IObjectWithSite, IObjectWithSelection interface to show context menu item.
I want to hide registered context menu item by using GetState return ECS_HIDDEN, but it does not work??

IFACEMETHODIMP GetState(IShellItemArray * psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
{
*pCmdState = ECS_HIDDEN;
return S_OK;
}

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,585 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2021-01-05T02:15:55.117+00:00

    Hello @Jojo Tang ,

    The shell treats ECS_HIDDEN the same as ECS_DISABLED for context menu items added via IExplorerCommand, where the menu item is disabled. An alternate approach is to implement a context menu handler, where the shell extension can decide whether to add an item to the menu in IContextMenu::QueryContextMenu.

    Thank you!


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.