Skip to content

A sample ThumbnailProvider shell extension implemented in .NET.

Notifications You must be signed in to change notification settings

tomasbut/ThumbnailProvider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ThumbnailProvider Shell Extension Demo (.NET 8)

This project focuses on creating a Windows shell extension for generating thumbnails. Writing shell extensions in .NET is opinionated but here we go. There are 3 interfaces that the thumbnail provider can use to initialize the thumbnail:

  • IInitializeWithStream - file stream is passed in as an argument
  • IInitializeWithFile - file path is passed in as an argument
  • IInitializeWithItem - ShellItem is passed in as an argument

Microsoft suggests implementing the IInitializeWithStream interface - this way the shell extension runs out of process, providing extra security. To use IInitializeWithFile or IInitializeWithItem we need to opt out of the process isolation feature by setting the following registry value:

- HKEY_CLASSES_ROOT
    - CLSID
    - {Your thumbnail provider CLSID}
        DisableProcessIsolation = 1 (DWORD)

Choose the interface that suits your needs best.

Know-how

  • Build the project
  • Register the COM component
  • Enjoy the new thumbnails 😎

Regsvr32

regsvr32 is a tool used to register COM components. Registering the component will create two main keys inside the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{THUMBNAILPROVIDER_CLSID}
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\{ProgID}

To register the COM component:

regsvr32 "full\path\to\ThumbnailProvider.comhost.dll"

To unregister the COM component:

regsvr32 /u "full\path\to\ThumbnailProvider.comhost.dll"

ℹ️ Make sure you're executing these commands with elevated privileges.

ℹ️ If you're using DisableProcessIsolation = 1, the changes will be applied only after restarting the explorer.exe process.

Integration with Cloud Filter API

For folks trying to make this work with Cloud Filter API:

  • Implement the IInitializeWithItem interface (not IInitializeWithFile or IInitializeWithStream)
  • Insert a string value pointing to your thumbnail provider CLSID:
- ...
    - Windows
        - CurrentVersion
            - Explorer
                - SyncRootManager
                    - [Your sync root id]
                        ThumbnailProvider = {THUMBNAILPROVIDER_CLSID}

That's it, from now on all file thumbnails under the sync root should be generated by our ThumbnailProvider.

About

A sample ThumbnailProvider shell extension implemented in .NET.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages