Click here to Skip to main content
12,693,891 members (33,010 online)
Click here to Skip to main content
Add your own
alternative version

Stats

69.6K views
5.1K downloads
66 bookmarked
Posted

Explorer Shell Context Menu

, 27 May 2008 CPOL
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...

Pro

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
memberMazen el Senih24-Sep-12 7:56 
General"Send to" menu visible but doesn't execute. Pin
Member 45122121-Dec-10 6:22
memberMember 45122121-Dec-10 6:22 
AnswerRe: "Send to" menu visible but doesn't execute. Pin
iprog223-Jul-12 1:04
memberiprog223-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
iprog223-Jul-12 0:59
memberiprog223-Jul-12 0:59 
GeneralRe: Add my menu to shell context menu Pin
Member 1016658923-Jul-13 23:41
memberMember 1016658923-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
Member 45122121-Dec-10 2:55
memberMember 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
fabricedupre@free.fr9-Mar-16 10:30
memberfabricedupre@free.fr9-Mar-16 10:30 
Generalnot good on win 7 Pin
thanhl0v328-Feb-10 18:27
memberthanhl0v328-Feb-10 18:27 
GeneralGreat! Pin
Jose M. Menendez Poó27-May-08 11:19
memberJose M. Menendez Poó27-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 
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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 27 May 2008
Article Copyright 2007 by Jpmon1
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid