How can I remove an item from the items obtained from the main File Explorer menu (IContextMenu) and add a new item along with an icon?

Mansour_Dalir 2,036 Reputation points
2025-03-10T11:29:34.21+00:00

Based on the answer already given (previous question), I wanted to customize the resulting items so that some of them are not visible and add a few of my own items so that I can do something from the click event on the custom item. If possible, please edit the text of one of the items. Thank you all.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,798 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 33,781 Reputation points Microsoft External Staff
    2025-03-11T07:01:33.5833333+00:00

    Hi @Anonymous ,

    To modify the context menu retrieved from IContextMenu, you'll need to:

    1. Remove an existing menu item: This can be done by modifying the menu handle (hMenu) returned by QueryContextMenu.
    2. Remove/Add a custom menu item: This can be achieved using the RemoveMenu and AppendMenu API.
    3. Assign an icon: You can use SetMenuItemBitmaps or ModifyMenu to associate an icon with the custom menu item.

    Best Regards.

    Jiachen Li


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 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.

    0 comments No comments

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.