Click here to Skip to main content
14,936,036 members
Articles / Programming Languages / C#
Article
Posted 10 Dec 2007

Stats

104.5K views
7K downloads
70 bookmarked

Explorer Shell Context Menu

Rate me:
Please Sign up or sign in to vote.
4.50/5 (20 votes)
27 May 2008CPOL
Add the Windows Explorer Shell Context Menu to your application
Screenshot -

Introduction

I am currently working on an Advanced text editor, and I was looking for a way to implement the Window's shell context menu in my code. I came across Andreas Johansson's WebLog which provided me with the answer. He took some of the code that Steven Roebert created and placed it in one file for ease of use. His code had several errors that were easily corrected, and now I am posting the finished product.

Using the Code

The code is pretty straightforward to use:

  1. Add the ShellContextMenu.cs file to your project.
  2. Create a new instance of the ShellContextMenu class.
  3. Call the ShowContextMenu method with the proper arguments.
    1. FileInfo/DirectoryInfo Array - A list of files/directories that need the Context Menu
    2. Point - Point to Display Context Menu
C#
// Sample code

ShellContextMenu ctxMnu = new ShellContextMenu();
FileInfo[] arrFI = new FileInfo[1];
arrFI[0] = new FileInfo(this.treeMain.SelectedNode.Tag.ToString());
ctxMnu.ShowContextMenu(arrFI, this.PointToScreen(new Point(e.X, e.Y)));

History

  • 12/10/07 - Created article
  • 27/05/08 - Cleaned code a bit

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jpmon1
Software Developer Halliburton
United States United States

Comments and Discussions

 
QuestionApps in open with submenu doesn't work Pin
baconYao3-Dec-20 15:29
MemberbaconYao3-Dec-20 15:29 
AnswerRe: Apps in open with submenu doesn't work Pin
baconYao8-Dec-20 21:45
MemberbaconYao8-Dec-20 21:45 
QuestionMultiple file Pin
Member 137674963-Aug-19 4:40
MemberMember 137674963-Aug-19 4:40 
BugMoving files blocks UI Pin
davidcole10-Feb-14 4:53
Memberdavidcole10-Feb-14 4:53 
BugProblem with drive Pin
davidcole30-Dec-13 13:12
Memberdavidcole30-Dec-13 13:12 
GeneralMy vote of 5 Pin
Mazen el Senih24-Sep-12 6:56
professionalMazen el Senih24-Sep-12 6:56 
General"Send to" menu visible but doesn't execute. Pin
Roland Schneider 45122121-Dec-10 5:22
MemberRoland Schneider 45122121-Dec-10 5:22 
AnswerRe: "Send to" menu visible but doesn't execute. Pin
NuFox Hast23-Jul-12 0:04
MemberNuFox Hast23-Jul-12 0:04 
GeneralAdd my menu to shell context menu Pin
Jen8915-Nov-10 3:28
MemberJen8915-Nov-10 3:28 
AnswerRe: Add my menu to shell context menu Pin
NuFox Hast22-Jul-12 23:59
MemberNuFox Hast22-Jul-12 23:59 
GeneralRe: Add my menu to shell context menu Pin
Murdahl23-Jul-13 22:41
MemberMurdahl23-Jul-13 22:41 
GeneralDoes not work on 64 bit Pin
uhax10119-Jun-10 1:55
Memberuhax10119-Jun-10 1:55 
GeneralRe: Does not work on 64 bit Pin
Roland Schneider 45122121-Dec-10 1:55
MemberRoland Schneider 45122121-Dec-10 1:55 
GeneralRe: Does not work on 64 bit Pin
Member 1032848630-Jul-14 21:34
MemberMember 1032848630-Jul-14 21:34 
AnswerSome tweaks (drives, files and folders, desktop items) Pin
MANSATAN29-Apr-10 11:28
MemberMANSATAN29-Apr-10 11:28 
QuestionRe: Some tweaks (drives, files and folders, desktop items) Pin
Member 795200327-May-11 19:18
MemberMember 795200327-May-11 19:18 
AnswerRe: Some tweaks (drives, files and folders, desktop items) Pin
Jpmon131-May-11 4:00
MemberJpmon131-May-11 4:00 
QuestionRe: Some tweaks (drives, files and folders, desktop items) Pin
matthew4392-Aug-11 8:58
Membermatthew4392-Aug-11 8:58 
AnswerRe: Some tweaks (drives, files and folders, desktop items) Pin
davidcole22-Jan-14 11:57
Memberdavidcole22-Jan-14 11:57 
GeneralRe: Some tweaks (drives, files and folders, desktop items) Pin
Colin Lamarre2-Mar-18 2:15
MemberColin Lamarre2-Mar-18 2:15 
GeneralRe: Some tweaks (drives, files and folders, desktop items) Pin
fabricedupre@free.fr9-Mar-16 9:30
Memberfabricedupre@free.fr9-Mar-16 9:30 
GeneralRe: Some tweaks (drives, files and folders, desktop items) Pin
Swatto8617-Mar-19 12:59
MemberSwatto8617-Mar-19 12:59 
Generalnot good on win 7 Pin
so0_lanhlung228-Feb-10 17:27
Memberso0_lanhlung228-Feb-10 17:27 
GeneralGreat! Pin
JoseMenendez27-May-08 10:19
MemberJoseMenendez27-May-08 10:19 
GeneralGreat, but needs a bit tweaking Pin
ZeroXX24-Mar-08 12:08
MemberZeroXX24-Mar-08 12:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.