問題描述
我需要在我的應(yīng)用程序中顯示文件的系統(tǒng)菜單.此菜單與圖像相同.
I need to show system menu of a file in my application. This menu same as the image.
而且,我還想在這個(gè)菜單中添加一個(gè)我的菜單元素.
And, I also want to add a my menu element to this menu.
我該怎么辦?
謝謝
推薦答案
您要查找的內(nèi)容稱為 shell 上下文菜單.要在您的應(yīng)用程序中顯示這樣的菜單,您必須調(diào)用 Windows API.這一點(diǎn)都不容易,但幸運(yùn)的是,其他人已經(jīng)嘗試了它.
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.
CodeProject 上的 C# 文件瀏覽器 有一個(gè) shell 上下文菜單,在那篇文章中也有描述.
The C# File Browser on CodeProject has a shell context menu, which is also described in that article.
然后 Andreas Johansson 從該項(xiàng)目中提取 shell 上下文菜單代碼并將其上傳為一個(gè)單獨(dú)的 ZIP 文件,您可以此處下載.
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.
我不知道如何使用它,甚至不知道它是否有效.這留給讀者作為練習(xí).但是如果你深入研究代碼,你可以從中學(xué)到很多東西.
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.
這篇關(guān)于如何在C#中顯示文件的系統(tǒng)菜單的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!