How do we register Shell extension with a certain file extension
I have tested a small shell extension referring to the article on code project. Though the whole process is quite complicated , I have some how idea what are the follwoing methodsand what do thet do.:
Initialize,DragQueryFile,GetCommandString,InvokeCommand,QueryContextMenu
But after reading through it I can not understand how Our ContextMenu Extension is being associated with .txt file.
The article explains if we will have a look inside .rgs file we can see that it create a registry entry like this:
HKCR
{
NoRemove txtfile
{
NoRemove ShellEx
{
NoRemove ContextMenuHandlers
{
ForceRemove SimpleShlExt = s '{5E2121EE-0300-11D4-8D3B-444553540000}'
}
}
}
}
But in actual, after following the article and writing the code , when I opened SimpleShlExt.rgs
It looks something like this:
--Edit As in CodeProject--
HKCR
{
NoRemove CLSID
{
ForceRemove {1E569362-E0A6-4DEA-AB1F-67D6D3DEF1A5} = s 'SimpleShExt Class'
{
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
}
}
}
Does the registry Dynamically creating any mapping bettwen the CLSID and txtfile reg entry.
If that is the case , if I want to modify the behaviour for any other File , for example for mp3 file or drive itself and I want my Context menu to Pop-Up or displayed , then how to go about it. Because 开发者_JAVA百科I don't know the CLSID for that.
One possibility is to register your context menu for all the file extensions you want to support. The other possibility is to register your extension in the wildcard / * class. It will then be instanciated for all files. You can then decide whether the context menu should be visible for this file or not. This can be done by using the IDataObject argument of IShellExtInit::Initialize.
You have to add the part to register with the txt file extension manually to your rgs file. Visual Studio only adds the part to register the shell extension.
Assuming your lib's uuid
is 5E2121EE-0300-11D4-8D3B-444553540000
, then use the following to associate your shell extension with *.txt
and *.tab
files. Add another block per each new extension:
NoRemove .txt
{
NoRemove shellex
{
{00021500-0000-0000-C000-000000000046} = s '{5E2121EE-0300-11D4-8D3B-444553540000}'
}
}
NoRemove .tab
{
NoRemove shellex
{
{00021500-0000-0000-C000-000000000046} = s '{5E2121EE-0300-11D4-8D3B-444553540000}'
}
}
精彩评论