Home Archive Integrating C# with Explorer Context Menu Item
|
|
Integrating C# with Explorer Context Menu Item |
|
|
|
Integrating C# Winform with Explorer Context Menu Item Awhile back in a post that I shall dub Part 1, we talked about how to create the context menu in explorer that would point to a program. Today it's time to show how little code it requires to send a path to a winform app.
Adding entries to Explorer context menu easily – How ? Add items to Windows Explorer context menu easily with Windows Explorer Shell Context Menu. This powerful component for your own, custom items appending to Windows Explorer Shell context menu will add all your application entries to the Explorer context menu. This .Net component with full C# and VB.NET support include detailed C# and VB.NET samples, tutorials and support all you may need to add your items to context menu : - Add all your items to Windows Explorer Shell context menu to be shown on any Windows operating system (all OS are supported – XP, Vista, Windows x64 , etc.)
- Add items to Windows Explorer Shell context menu to be shown in any way - with your custom caption and icon, as separator or sub-menu
- Add your items to Windows Explorer Shell context menu to be shown for all files or shown only for files of particular type (for example, only for .DOC , .MP3,.WMA,.AAC , .AVI files)
- Add your program items to Windows Explorer Shell context menu, sub-menus, sub-menus of unlimited depth and even more
Windows Explorer Shell Context Menu - is a .Net framework component that support all you may need to add all your program items to the Windows Explorer Shell context menu - in a fast and easy way. Add all your program items to Explorer Shell context menu right now – fast and exactly as you prefere :
C# Winform integration method with Windows Explorer contect menu, described here, works only on Windows 95 / Windows 98 (not on XP, Vista, x64 - 64-bit Windows), to add items to Windows Explorer Shell context menu you should use, according to Microsoft guidelines, appropriate .Net component - Windows Explorer Shell Context Menu. Open up your Program.cs (in 2.0) or whatever class that contains your Main method. Make your method designation the same as below:
static void Main(string[] args)
This will allow arguments to be passed into the method from an outside source. Inside your method you'll want:
Form1 f = new Form1();
if (args.Length > 0)
{
f.Path = args[0];
}
Application.Run(f);
This will set the Path variable on your winform to the argument passed in. Do what you will with your public accesor. Mine looks like:
public string Path
{
get { return this.fbd.SelectedPath; }
set
{
this.fbd.SelectedPath = value;
this.txtDirectory.Text = value;
}
} |
|