Click here to Skip to main content
6,305,776 members and growing! (15,552 online)
Email Password   helpLost your password?
Languages » C# » Utilities     Intermediate License: The Code Project Open License (CPOL)

Explorer Shell Context Menu

By Jpmon1

Add the Windows Explorer Shell Context Menu to your application
C# (C# 1.0, C# 2.0, C# 3.0), .NET (.NET 2.0), Dev, Design
Posted:10 Dec 2007
Updated:27 May 2008
Views:11,507
Bookmarked:33 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
12 votes for this article.
Popularity: 4.00 Rating: 3.71 out of 5
1 vote, 8.3%
1
1 vote, 8.3%
2
2 votes, 16.7%
3
1 vote, 8.3%
4
7 votes, 58.3%
5
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)

About the Author

Jpmon1


Member
Jon Likes to Code.
Occupation: Software Developer
Company: Halliburton
Location: United States United States

Other popular C# articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralGreat! PinmemberJose M. Menendez Poó11:19 27 May '08  
GeneralGreat, but needs a bit tweaking PinmemberZeroXX13:08 24 Mar '08  
GeneralShort and Sweet PinmemberThe_Mega_ZZTer17:39 10 Dec '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 May 2008
Editor: Deeksha Shenoy
Copyright 2007 by Jpmon1
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project