我们如何注册具有特定文件扩展名的 Shell 扩展

发布于 2024-09-24 17:49:19 字数 1136 浏览 1 评论 0原文

我已经测试了一个小型 shell 扩展,参考代码项目的文章。虽然整个过程相当复杂,但我知道以下方法是什么以及它们的作用:

Initialize,DragQueryFile,GetCommandString,InvokeCommand,QueryContextMenu

但读完后我不明白如何我们的 ContextMenu 扩展与 .txt 文件关联。

该文章解释了如果我们查看 .rgs 文件内部,我们可以看到它创建了一个如下所示的注册表项:

HKCR
{
  NoRemove txtfile
  {
    NoRemove ShellEx
    {
      NoRemove ContextMenuHandlers
      {
        ForceRemove SimpleShlExt = s '{5E2121EE-0300-11D4-8D3B-444553540000}'
      }
    }
  }
}

但实际上,在按照文章进行操作并编写代码后,当我打开 SimpleShlExt.rgs 它看起来像这样:

--按 CodeProject 中的方式编辑--

HKCR
{

    NoRemove CLSID
    {
        ForceRemove {1E569362-E0A6-4DEA-AB1F-67D6D3DEF1A5} = s 'SimpleShExt Class'
        {

            InprocServer32 = s '%MODULE%'
            {
                val ThreadingModel = s 'Apartment'
            }

        }
    }
}

注册表是否动态创建 CLSID 和 txtfile 注册表项之间的任何映射。

如果是这种情况,如果我想修改任何其他文件的行为,例如 mp3 文件或驱动器本身,并且我希望弹出或显示上下文菜单,那么该怎么做。因为我不知道它的 CLSID。

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 I don't know the CLSID for that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

少钕鈤記 2024-10-01 17:49:19

一种可能性是为您想要支持的所有文件扩展名注册上下文菜单。另一种可能性是在通配符 / * 类中注册您的扩展。然后将为所有文件实例化它。然后您可以决定该文件的上下文菜单是否可见。这可以通过使用 IShellExtInit::Initialize 的 IDataObject 参数来完成。

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.

小红帽 2024-10-01 17:49:19

您必须将要使用 txt 文件扩展名注册的部分手动添加到您的 rgs 文件中。 Visual Studio仅添加注册shell扩展的部分。

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.

刘备忘录 2024-10-01 17:49:19

假设您的 lib 的 uuid5E2121EE-0300-11D4-8D3B-444553540000,然后使用以下命令将您的 shell 扩展与 *.txt 关联,并*.tab 文件。每个新扩展添加另一个块:

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}'  
    }  
}

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}'  
    }  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文