{"id":92342,"date":"2015-12-08T07:00:00","date_gmt":"2015-12-08T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20151208-00\/?p=92342\/"},"modified":"2019-03-13T12:22:38","modified_gmt":"2019-03-13T19:22:38","slug":"20151208-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20151208-00\/?p=92342","title":{"rendered":"How do I register a command on the desktop background context menu? (And how do I remove one I don&#8217;t like?)"},"content":{"rendered":"<p>To register a command to appear on the context menu for the desktop background, you put it under the predefined shell object <code>Desktop&shy;Background<\/code>. (For some reason, this predefined object is not on the list of predefined objects, although its existence is betrayed on <a HREF=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/cc144171(v=vs.85).aspx#specify_order_verbs\">this page<\/a>.) As with all progids, simple commands can be registered under the <code>shell<\/code> key; complex commands can be registered under the <code>shellex<\/code> key. For example, this registration adds an entry called CharMap that runs, um, CharMap. In case you wanted to be able to launch CharMap right from the desktop context menu.<\/p>\n<pre>\n[HKEY_CLASSES_ROOT\\DesktopBackground\\shell\\CharMap\\command]\n@=\"charmap.exe\"\n<\/pre>\n<p>Many shell extensions choose to register under <code>Directory\\Background<\/code>, and then perform a test at runtime to see if the directory is the desktop. If so, then they add the extension; if not, they suppress it. <\/p>\n<p>Therefore (reading the contract from the other side), if you want to remove an item that some random third party added to your desktop context menu (for some reason, video card manufacturers <i>love<\/i> adding stuff to the desktop context menu), you can go spelunking into <\/p>\n<pre>\nHKEY_CLASSES_ROOT\\\n    DesktopBackground\\\n<\/pre>\n<p>and <\/p>\n<pre>\nHKEY_CLASSES_ROOT\\\n    Directory\\\n        Background\\\n<\/pre>\n<p>When I do this, I prefer not to delete the registry key entirely, because who knows, maybe someday I want to re-enable it. In the case of a context menu shell extension, I disable it by reversibly corrupting the CLSIDs. <\/p>\n<pre>\nHKEY_CLASSES_ROOT\\\n    DesktopBackground\\\n        shellex\\\n            ContextMenuHandlers\\\n                x{########-####-####-####-############}\\\n                    @=\"x{########-####-####-####-############}\"\n\nHKEY_CLASSES_ROOT\\\n    Directory\\\n        Background\\\n            shellex\\\n                ContextMenuHandlers\\\n                    x{########-####-####-####-############}\\\n                        @=\"x{########-####-####-####-############}\"\n<\/pre>\n<p>By putting an x in front of the curly brace, I prevent the key name or value from being parsed successfully as a CLSID, but I can easily re-enable the extension by removing the x. <\/p>\n<p>Note that most registrations will not have two CLSIDs. Some will put a CLSID in the key name, and others will put the CLSID as a value under the key. So whichever one you see, stick an x in front. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Places to go, and places to look.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25,104],"class_list":["post-92342","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>Places to go, and places to look.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/92342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=92342"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/92342\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=92342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=92342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=92342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}