Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Explorer Shell Context Menu

0.00/5 (No votes)
27 May 2008 2  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here