c# - Shell extension - on the explorer window -
i'm creating shell extension in c# using microsoft source code registering , unregistering shell context menu handler.
the registration looks that:
public static void registershellextcontextmenuhandler(guid clsid, string filetype, string friendlyname) { if (clsid == guid.empty) { throw new argumentexception("clsid must not empty"); } if (string.isnullorempty(filetype)) { throw new argumentexception("filetype must not null or empty"); } // if filetype starts '.', try read default value of // hkcr\<file type> key contains progid file type // linked. if (filetype.startswith(".")) { using (registrykey key = registry.classesroot.opensubkey(filetype)) { if (key != null) { // if key exists , default value not empty, use // progid file type. string defaultval = key.getvalue(null) string; if (!string.isnullorempty(defaultval)) { filetype = defaultval; } } } } // create key hkcr\<file type>\shellex\contextmenuhandlers\{<clsid>}. string keyname = string.format(@"{0}\shellex\contextmenuhandlers\{1}", filetype, clsid.tostring("b")); using (registrykey key = registry.classesroot.createsubkey(keyname)) { // set default value of key. if (key != null && !string.isnullorempty(friendlyname)) { key.setvalue(null, friendlyname); } } }
the second parameter file type extenstion work on , example i'm passing that:
shellextreg.registershellextcontextmenuhandler(t.guid, ".cs", "csshellextcontextmenuhandler.filecontextmenuext class");
if want folder , not file type pass "directory"
my question how can make extension work when right click on explorer window self , not on specific file or folder
Comments
Post a Comment