C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Add your application name to the Windows Context Menu


Posted Date: 23 May 2008    Resource Type: Code Snippets    Category: Application windows, menus & toolbars
Author: Payal JainMember Level: Gold    
Rating: Points: 10



introduction


this code will help u to add your application to windows context menu of selected file.

namespaces used


namespace used for this is Microsoft.Win32 which is imported using

using Microsoft.Win32;

Description and Code



to add your application to windows context menu of selected file , you only need to create one registry key in HKEY_CLASSES_ROOT\*\Shell with the user defined name and one in this newly created key with name command which is pointing to your application. This is done your application is now added to windows context menu and when you click on thi your application will get started. and to create registry key you will need to call SetValue method of Registry Class.
here is the code :


Registry.SetValue(@"HKEY_CLASSES_ROOT\*\Shell\myapp2", "", "myapp2", RegistryValueKind.String);

Registry.SetValue(@"HKEY_CLASSES_ROOT\*\Shell\myapp2\Command", "", "notepad.exe", RegistryValueKind.String);



here second parameter is an empty string because we want to set default value of the key created. 3rd parameter in first line (i.e, myapp2) is the name that you want to display in the context menu. 3rd parameter in second line (i.e. "notepad.exe" ) is the application exe name that you want to open on clicking the option in context menu . if you want the selected file should open in the application then this parameter will be "notepad.exe %1" attaching %1 with the application name will pass the file name to be opened on starting the application.

Attachments







Responses

Author: Abhishek Arya    23 May 2008Member Level: Diamond   Points : 2
good one


Author: mani kumar.k.m    24 May 2008Member Level: Gold   Points : 2
Hi,

this code snippets usefull to me. nice example.

thanks


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Adding your application to the System Tray on minimization
Previous Resource: How to use Tooltip to your project
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use