How can I create my custom Shell Context Handlers for Windows?

前端 未结 7 574
滥情空心
滥情空心 2020-12-17 04:39

Problem

Language: C# 2.0 or later


I would like to register context handlers to create menues when the user right clicks certain files (in my case *.e

7条回答
  •  有刺的猬
    2020-12-17 05:20

    Aside from the caveats that have been mentioned concerning the implementation of shell extensions in managed code, what you'd basically need to do is the following:

    First, create a COM component in C# that implements the IShellExtInit IContextMenu interfaces. How to create COM components in C# is described here. How to implement the necessary interfaces is described in this article. While the description is for a C++ implementation, you can apply that knowledge to you C# version.

    Your COM component will have GUID called the Class-ID or CLSID. You need to register that ID with your file type as a context-menu shell extension:

    HKEY_CLASSES_ROOT\.eic\ShellEx\ContextMenuHandlers\MyShellExt
        (Default) -> {YOUR-COMPONENTS-CLSID}
    

    Also make sure that you registered your component correctly as described in the C# COM tutorial. You should find it in the registry under

    HKEY_CLASSES_ROOT\CLSID\{YOUR-COMPONENTS-CLSID}
        InprocServer32
            (Default) -> C:\WINDOWS\system32\mscoree.dll
            Class -> YourImplClass
            assembly -> YourAssembly, version=..., Culture=neutral, PublicKey=...
            ...
    

    Good luck...

提交回复
热议问题