Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

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

I'm currently writing an application where I need to modify the context menu of windows explorer so that I can call a method within the application to be used on all files/folders that are seen in windows explorer.

As there are already quite a few posts on stackoverflow (and also tutorials) on how to add the context menu for specific file types I know already that that is done usually by assigning the application to the right parts of the registry entry for those file types.

As I don't want to limit myself to only specific filetypes my question is: IS there any way to assign this new context menu item to ALL filetypes (aside from going through each registry entry beginning with . and assigning the application to them there)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, the * class:

  1. Create the key:

    HKEY_CLASSES_ROOT*shellOpen with MyThing

  2. Create the sub key:

    HKEY_CLASSES_ROOT*shellOpen with MyThingcommand

  3. Set the default value to your command line:

    C:foomyThing.exe "%1"

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

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

    HKEY_CLASSES_ROOT*shellOpen with MyThing

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


Example

cap1

For:

cap2


.Reg

Windows Registry Editor Version 5.00

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

[HKEY_CLASSES_ROOT*shellOpen with MyThingcommand]
@="C:\foo\myThing.exe "%1""

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...