I want to add an item into the Desktop context menu (the menu you see when you right-click on an empty space on the Windows Desktop).
Something like Catalyst Control Center in this screenshot:
I know how to add items to files' and folders' context menus through registry, but the Desktop seems to work differently: I didn't even find the text in the registry.
So, how can I add a new item into the Desktop menu and how can I associate some code with it?
I think the solution is language independent, if it's not, I'd appreciate any code that helps.
Such a handler must be registered in HKCR\Directory\Background, instead of usual locations like HKCR\Directory, HKCR\Folder, etc.
Check out Creating Shell Extension Handlers in MSDN.
There's a series of articles on CodeProject that details writing Shell Extensions and is very good:
http://www.codeproject.com/KB/shell/shellextguide1.aspx
Related
Is there a way to "Grey Out" or disable Windows Context Menu entrys?
I created a few entrys by adding them in the Windows Registry. So far so good. But they should not always be clickable (but still visible).
Googling this problem didn't help me. An Example is the Right-Click Menu of the Recycle Bin. When it's full the "Empty" -Entry is clickable, when it's empty it's greyed out.
You're looking for Shotcut Menu Handlers (MSDN) or Shell Extension Providers (MSDN)
It's not just about INI files and Registry entries. You'll need to implement a COM object that adheres to some interfaces, e.g. IContextMenu.
A useful utility is NirSoft ShellExView.
how to add new items to certain file extension context menu (to .mp3 files for instance)
I've also noticed that there is common items in all context menus across the windows, does they all share/inherit one context menu ? where is it : which one is for text
what such keys are called and how to generate them (for instance {11dbb47c-a525-400b-9e80-a54615a090c0})
also is there a good brief reference for the registry that you would recommend ?
Type regedit in RUN dialog box or Start Menu searchbox and press Enter. It'll open Registry Editor, now go to following keys:
HKEY_CLASSES_ROOT* (for adding an option in All files context menu)
HKEY_CLASSES_ROOT\Directory (for adding an option in folders context menu only)
HKEY_CLASSES_ROOT\Drive (for adding an option in Drives context menu only)
HKEY_CLASSES_ROOT\Unknown (for adding an option in unknown files context menu)
Now under the above mentioned keys, you'll find "Shell" and "Shellex" keys. Both keys contain various entries, which are displayed when you right-click on a file, folder or drive. We'll use "Shell" key in this example:
Right-click on the "Shell" key and select "New -> Key".
Give it any name. Suppose we gave it name "Demo".
Now in right-side pane, double-click on "Default" String value and set its value to the Label which you want to display in context menu. Like if you want to add "Winamp" in context menu, then you can give it name "Open with Winamp" or similar.
Now create another key under this newly created key "Demo" with the name "command" and in right-side pane set value of "Default" to the path of application. For ex, for winamp you can set its value %programfiles%\Winamp\winamp.exe.
A full reference to this can be found here
how to add new items to certain file extension context menu
How you massage the registry to create context menu item entries is already covered by this MSDN article. It is extensive and well done, no need to repeat it here.
I've also noticed that there is common items in all context menus across the windows
The majority of them are baked-in items that Explorer itself understands. There is a backdoor to add an item yourself to any file, the HKCR\* registry key is used. Use this sparingly, it is pretty annoying to users.
for instance {11dbb47c-a525-400b-9e80-a54615a090c0}
That's an example of a custom shell extension handler, you found this one back in the HKCR\Folder registry key, the key that adds items to any directory. Think of it as a plug-in that adds capabilities to Explorer that it doesn't have itself. The {guid} selects the executable file that Explorer loads to implement the item. Navigate to HKCR\Classes\CLSID\{guid} to see that file, you'll see it is implemented by c:\windows\system32\explorerframe.dll
Writing your own shell extension handler is not that easy, it requires COM coding skills in C++. A coding technique that is getting obscure. Using something like C# is technically possible but strongly discouraged by Microsoft and they won't support it. You need to write an in-process COM server that implements the IContextMenu interface. Programming guide is here.
desktop: window server 2003
Assume i have a cmd.sh that echo a message, here i want to run it in anywhere , when i right click the mouse and choose the echo function.
hope for your answer, thanks
Editing the registry as #dbvega indicates works if you always want the same menu item to appear. This is called a static menu. But if you want to do have more control over your menu item, such as changing the visibility, text, and icon depending on various runtime conditions, you need to create a dynamic context menu shell extension, which involves programming a COM object. This MSDN article describes the difference.
I have a toolbar with some actions linked to macros in Personal.xls. I want to use the toolbar in Excel 2010 under Win7, but it insists C:\Documents and Settings\user\App...\PERSONAL.XLS doesn't exist. Quite right, they've changed the %AppData% location to C:\Users\user... And I can't put a copy of PERSONAL.XLS in the old place because C:\Documents and Settings\ is special-cased in Windows 7, and it's a forbidden place to everyone.
My question: How can I reset the macro linked to the toolbar buttons?
You used to be able to access
the Commandbars collection to get a command bar
The Controls collection of the command bar to get a control (button in this case)
The OnAction property of the control to identify the linked macro.
But OnAction doesn't seem to be a supported property for Excel 2010.
Any suggestions?
I'd much rather relink the toolbar than create a new custom ribbon tab. The toolbar buttons don't waste the APALLING amount of space custom ribbon items take up, and the custom icons on my toolbarare meaningful. Subsiduary question: Are there simple ways to create custom designs for custom ribbon items?
Looks like I didn't investigate closely enough. "OnAction" might not appear in the Object Browser, but it is available, and can be used to reset the associated toolbars. It didn't seem to work using the Immediate window, but does work within code in a module.
Cheers folks...
I would like to create menu item in windows explorer content menu (for all file types) which after click will open my application and pass the selected file name to it. Is there any tutorial for this ? I know there is ShellPlus component available but it's a bit outdated.
Registry
This method is easy since it comes down to adding some registry keys. The downside is that you can't put any logic in it. You can read about it here and here a simple example in Delphi. You get a bit more control if you are using DDE to execute the menu items. See here for a Delphi example.
Shell Extension
This method is a bit more work, but you can completely control the context menu from code. You would have to write a DLL, implement IContextMenu (or others) and register the dll with Windows Explorer. You can read about it here. You already mentioned Shell+.
Delphi includes a demo project for shell extensions. Look in the Demos\ActiveX\ShellExt folder.
This is possible independendly from the programming language by setting up shortcut menu handlers for the desired filetype(s) in the registry. There you can call your application with the correct path, the correct options and the right file-placeholders.
See the MSDN article on Creating Shortcut Menu Handlers for more detailled information.