Click here to Skip to main content
5,788,961 members and growing! (20,787 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, C#), .NET (.NET, .NET 2.0), Dev, Design

Posted: 10 Dec 2007
Updated: 27 May 2008
Views: 7,656
Bookmarked: 31 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
9 votes for this Article.
Popularity: 3.03 Rating: 3.18 out of 5
1 vote, 11.1%
1
1 vote, 11.1%
2
2 votes, 22.2%
3
1 vote, 11.1%
4
4 votes, 44.4%
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


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

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Search Search Messages 
 Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralGreat!memberJose M. Menendez Poó11:19 27 May '08  
GeneralGreat, but needs a bit tweakingmemberZeroXX13:08 24 Mar '08  
GeneralShort and SweetmemberThe_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
Web13 | Advertise on the Code Project