Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File association and thumbnail preview in Windows 10

I have created an application and associated on registry a file extension on Windows 10, so when you double click a file associated with my extension, it opens my app with the file as parameter.

Now, I want the files associated to my application to behave in Windows 10 just like images - I mean, having a thumbnail preview, so when the user selects "large icons", he would be able to see a preview of the file.

I wonder how can I do it. What kind of metadata my file should have so Windows would recognize it and show a preview. Of course, I don't want just large icons, I want a file preview just like image files.

It isn't hard for me to generate a preview bitmap and integrate it to the file format I created (or even to change the file format completely, since I didn't publish anything yet), but how would windows recognize it? Is this even possible?

Thanks in advance

like image 512
Leonardo Alves Machado Avatar asked Mar 28 '16 20:03

Leonardo Alves Machado


People also ask

How do I get thumbnail previews in Windows 10?

Press Windows key + S and enter advanced system settings. Choose View advanced system settings from the menu. In the Performance section, click on the Settings button. Check Save taskbar thumbnail previews and Show thumbnails instead of icons.

How do I view file associations in Windows 10?

Windows allows you to change file associations by going into Settings > Apps > Default Apps and selecting at the bottom the option titled "Choose default apps by file type". This will open a screen that lists all of the configured extensions on the computer and the program associated with them.

How do I enable or disable thumbnail previews in File Explorer Windows 10?

Browse the following path: User Configuration > Administrative Templates > Windows Components > File Explorer. On the right side, double-click the Turn off the display of thumbnails and only display icons policy.


1 Answers

After some research, I found a sample code that does exactly what I need. It creates a thumbnail provider, which have access to the file's contents (binary), and then I can use it to generate the thumbnail of the file.

The sample that creates a IThumbnailProvider can be found here: https://code.msdn.microsoft.com/windowsapps/CppShellExtThumbnailHandler-32399b35/view/SourceCode#content

The project should generate a dll, that we should register on Windows. It might be done using the following lines:

system32/regsvr32 ThumbnailProviderx64.dll
syswow64/regsvr32 ThumbnailProviderx86.dll

unregistering is like this:

system32/regsvr32 /u ThumbnailProviderx64.dll
syswow64/regsvr32 /u ThumbnailProviderx86.dll

Another nice sample could be found at: http://www.codemonkeycodes.com/2010/01/11/ithumbnailprovider-re-visited/

like image 102
Leonardo Alves Machado Avatar answered Jan 27 '23 12:01

Leonardo Alves Machado