Windows 10 中的文件关联和缩略图预览

编程入门 行业动态 更新时间:2024-10-27 05:33:28
本文介绍了Windows 10 中的文件关联和缩略图预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在 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/windowsapps/CppShellExtThumbnailHandler-32399b35/view/SourceCode#content

The sample that creates a IThumbnailProvider can be found here: https://code.msdn.microsoft/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/2010/01/11/ithumbnailprovider-re-visited/

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

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

更多推荐

[db:关键词]

本文发布于:2023-04-30 14:37:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395743.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缩略图   文件关联   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!