C# adding context menu item to windows explorer for all file types

淺唱寂寞╮ 提交于 2019-11-29 12:03:08

Yes, the * class:

  1. Create the key:

    HKEY_CLASSES_ROOT\*\shell\Open with MyThing

  2. Create the sub key:

    HKEY_CLASSES_ROOT\*\shell\Open with MyThing\command

  3. Set the default value to your command line:

    C:\foo\myThing.exe "%1"

    (You can add fixed values here also: C:\foo\myThing.exe "%1" /ranfromshell)

  4. To set an optional icon create the string value Icon in:

    HKEY_CLASSES_ROOT\*\shell\Open with MyThing

    You can put the path to an icon, dll or exe here - Windows will extract the appropriate icon & display it.


Example

For:


.Reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with MyThing]
"Icon"="C:\\foo\\myThing.exe"

[HKEY_CLASSES_ROOT\*\shell\Open with MyThing\command]
@="C:\\foo\\myThing.exe \"%1\""
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!