Click here to Skip to main content
13,836,654 members
Click here to Skip to main content
Add your own
alternative version

Stats

88.9K views
6.1K downloads
67 bookmarked
Posted 10 Dec 2007
Licenced CPOL

Explorer Shell Context Menu

, 27 May 2008
Rate this:
Please Sign up or sign in to vote.
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
// 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

You may also be interested in...

Comments and Discussions

 
BugMoving files blocks UI Pin
davidcole10-Feb-14 5:53
memberdavidcole10-Feb-14 5:53 
BugProblem with drive Pin
davidcole30-Dec-13 14:12
memberdavidcole30-Dec-13 14:12 
GeneralMy vote of 5 Pin
Mazen el Senih24-Sep-12 7:56
professionalMazen el Senih24-Sep-12 7:56 
General"Send to" menu visible but doesn't execute. Pin
Roland Schneider 45122121-Dec-10 6:22
memberRoland Schneider 45122121-Dec-10 6:22 
AnswerRe: "Send to" menu visible but doesn't execute. Pin
NuFox Hast23-Jul-12 1:04
memberNuFox Hast23-Jul-12 1:04 
GeneralAdd my menu to shell context menu Pin
Jen8915-Nov-10 4:28
memberJen8915-Nov-10 4:28 
AnswerRe: Add my menu to shell context menu Pin
NuFox Hast23-Jul-12 0:59
memberNuFox Hast23-Jul-12 0:59 
GeneralRe: Add my menu to shell context menu Pin
Murdahl23-Jul-13 23:41
memberMurdahl23-Jul-13 23:41 
GeneralDoes not work on 64 bit Pin
uhax10119-Jun-10 2:55
memberuhax10119-Jun-10 2:55 
GeneralRe: Does not work on 64 bit Pin
Roland Schneider 45122121-Dec-10 2:55
memberRoland Schneider 45122121-Dec-10 2:55 
GeneralRe: Does not work on 64 bit Pin
Member 1032848630-Jul-14 22:34
memberMember 1032848630-Jul-14 22:34 
AnswerSome tweaks (drives, files and folders, desktop items) Pin
MANSATAN29-Apr-10 12:28
memberMANSATAN29-Apr-10 12:28 
QuestionRe: Some tweaks (drives, files and folders, desktop items) Pin
Member 795200327-May-11 20:18
memberMember 795200327-May-11 20:18 
AnswerRe: Some tweaks (drives, files and folders, desktop items) Pin
Jpmon131-May-11 5:00
memberJpmon131-May-11 5:00 
QuestionRe: Some tweaks (drives, files and folders, desktop items) Pin
matthew4392-Aug-11 9:58
membermatthew4392-Aug-11 9:58 
AnswerRe: Some tweaks (drives, files and folders, desktop items) Pin
davidcole22-Jan-14 12:57
memberdavidcole22-Jan-14 12:57 
GeneralRe: Some tweaks (drives, files and folders, desktop items) Pin
Colin Lamarre2-Mar-18 3:15
memberColin Lamarre2-Mar-18 3:15 
GeneralRe: Some tweaks (drives, files and folders, desktop items) Pin
fabricedupre@free.fr9-Mar-16 10:30
memberfabricedupre@free.fr9-Mar-16 10:30 
Generalnot good on win 7 Pin
so0_lanhlung228-Feb-10 18:27
memberso0_lanhlung228-Feb-10 18:27 
GeneralGreat! Pin
Jose Menendez Póo27-May-08 11:19
memberJose Menendez Póo27-May-08 11:19 
GeneralGreat, but needs a bit tweaking Pin
ZeroXX24-Mar-08 13:08
memberZeroXX24-Mar-08 13:08 
QuestionRe: Great, but needs a bit tweaking Pin
seguso20-Aug-09 8:48
memberseguso20-Aug-09 8:48 
AnswerRe: Great, but needs a bit tweaking Pin
MANSATAN29-Apr-10 12:35
memberMANSATAN29-Apr-10 12:35 
GeneralRe: Great, but needs a bit tweaking Pin
Colin Lamarre1-Mar-18 20:46
memberColin Lamarre1-Mar-18 20:46 
GeneralShort and Sweet Pin
The_Mega_ZZTer10-Dec-07 17:39
memberThe_Mega_ZZTer10-Dec-07 17:39 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190114.1 | Last Updated 27 May 2008
Article Copyright 2007 by Jpmon1
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid