C#通过Windows API的文件从获取缩略图 [英] C# get thumbnail from file via windows api
问题描述
Windows资源管理器显示文件的缩略图的能力。这些缩略图是由核心和第三方外壳扩展提供的。
Windows explorer has the ability to show thumbnails of files. These thumbnails are provided by core and third-party shell extensions.
我知道如何扩展外壳提供缩略图窗口。
I know how to extend the shell to provide thumbnails to Windows.
我想要做的是从通过使用C#壳系统上的任何文件检索缩略图。这可能吗?
What I want to do is retrieve the thumbnail image from any file on the system via the shell using C#. Is this possible?
从本质上讲,我正在写一个自定义的文件浏览器,我想显示缩略图,并且不可能解析每个文件在这个星球上,以使自己的缩略图。
Essentially, I'm writing a custom file browser and I want to show thumbnails, and can't possibly parse every file on the planet to make my own thumbnails.
澄清:
许多答案似乎周围的网页缩略图为中心,或缩放图像。但是,这根本不是我要找的。我要的是要问的Windows这些文件类型的缩略图重新presentation:.DOC,.PDF,使用.3dm,.DWG ......和mabye十几以上。我不想来解析,渲染,使自己的缩略图,因为Windows已经知道如何。
Clarification: Many answers seem to be centered around web page thumbnails, or scaling an image. But that's not at all what I'm looking for. What I want is to ask Windows for the thumbnail representation of these file types: .DOC, .PDF, .3DM, .DWG... and mabye about a dozen more. I don't want to parse, render, and make thumbnails myself, because Windows already knows how.
在code我张贴作为一个答案实际工作......也许它可以简化并清理了一下。
The code I posted as an answer actually works... maybe it can be simplified and cleaned up a bit.
推荐答案
今天这个跑过 - 这是一个几个月大,但它得到了我所做的工作(Win7上,对MPEG-4文件中提取缩略图):
Ran across this today -- it's a few months old, but it got the job done for me (on Win7, extracting thumbnails on MPEG-4 files):
<一个href=\"https://blogs.msdn.microsoft.com/windowssdk/2009/06/12/windows-api-$c$c-pack-for-microsoft-net-framework/\" rel=\"nofollow\">https://blogs.msdn.microsoft.com/windowssdk/2009/06/12/windows-api-$c$c-pack-for-microsoft-net-framework/
ShellFile shellFile = ShellFile.FromFilePath(pathToYourFile);
Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;
希望它帮助!
这篇关于C#通过Windows API的文件从获取缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!