This project has moved. For the latest updates, please go here.

ContextMenu: Registration for all extensions

Aug 17, 2010 at 5:35 PM
Edited Aug 17, 2010 at 5:36 PM
public class ContextMenu : ContextMenuBase { public ContextMenu() { // ??? I don't call RegisterExtension //RegisterExtension("*"); } protected override void QueryContextMenuCore(Menu menu, IList<string> filenames) { var myMenu = menu.AddSubMenu("MediaCenter", "MediaCenter commands"); myMenu.AddItem("&Open with notepad", "Open file with notepad", OnEditWithNotepadCommand); } private static void OnEditWithNotepadCommand(ref InvokeCommandInfo invokeCommandInfo, IList<string> fileNames) { Debug.Assert(fileNames.Count == 1, "fileNames.Count == 1"); //// Use the command line param to pass the exe filename. This causes //// Windows to use the path to find notepad. Process.Start("notepad.exe", "\"" + fileNames[0] + "\""); } [ComRegisterFunction] public static void ComRegisterFunction(Type type) { ComRegister(type, Name, "*"); } [ComUnregisterFunction] public static void ComUnregisterFunction(Type type) { ComUnregister(type, Name, "*"); } private const string Name = "ContextMenuTest"; } ----------------------------- It's works :) Is it correct? Another questions. How I can handle for example zip files('.zip' is redirected to '7-Zip.zip')? It looks that mmsf allows only one handler for file type if you don't know progID