How to show system menu of a file in C#

2020-07-27 06:12发布

问题:

I need to show system menu of a file in my application. This menu same as the image.

And, I also want to add a my menu element to this menu.

How can I do ?

Thanks

回答1:

What you're looking for is called a shell context menu. To display such a menu in your application, you'll have to call the Windows API. This is not at all easy, but fortunately for you some other people have taken a stab at it.

The C# File Browser on CodeProject has a shell context menu, which is also described in that article.

Then Andreas Johansson extracted the shell context menu code from that project and uploaded it as a separate ZIP file, which you can download here.

I have no idea how to use it, or even if it works. That's left as an exercise for the reader. But there is a lot you can learn from this if you dig into the code.