Windows 10 中的文件关联和缩略图预览 [英] File association and thumbnail preview in Windows 10

查看:41
本文介绍了Windows 10 中的文件关联和缩略图预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 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.

现在,我希望与我的应用程序关联的文件在 Windows 10 中的行为就像图像一样 - 我的意思是,具有缩略图预览,因此当用户选择大图标"时,他将能够看到预览文件.

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.

我想知道我该怎么做.我的文件应该有什么样的元数据,这样 Windows 才能识别它并显示预览.当然,我不想要大图标,我想要像图像文件一样的文件预览.

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.

生成预览位图并将其集成到我创建的文件格式中对我来说并不难(甚至完全更改文件格式,因为我还没有发布任何内容),但是 windows 将如何识别它?这甚至可能吗?

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?

提前致谢

推荐答案

经过一番研究,我找到了一个示例代码,它完全符合我的需要.它创建了一个缩略图提供程序,它可以访问文件的内容(二进制),然后我可以使用它来生成文件的缩略图.

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.

可以在此处找到创建 IThumbnailProvider 的示例:https://code.msdn.microsoft.com/windowsapps/CppShellExtThumbnailHandler-32399b35/view/SourceCode#content

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

该项目应该生成一个 dll,我们应该在 Windows 上注册.可以使用以下几行来完成:

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

注销是这样的:

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

可以在以下位置找到另一个不错的示例:http://www.codemonkeycodes.com/2010/01/11/ithumbnailprovider-re-visited/

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

这篇关于Windows 10 中的文件关联和缩略图预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆