如何从我的 WPF 应用程序访问 Windows 文件预览图标 [英] How can I access windows file preview icons from my WPF application

查看:31
本文介绍了如何从我的 WPF 应用程序访问 Windows 文件预览图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个目录中有一堆图片和视频,需要在 WPF 应用程序中显示,我正在考虑将 Win7 大图标本身显示为预览图像.因为这将节省我从视频文件中抓取适当帧的工作,因为 Windows 已经很好地完成了这项工作.任何访问此外壳图标图像数据的代码片段?

I got a bunch of Pictures and Videos in a directory and needs to be displayed in the WPF application, I am thinking about displaying the Win7 Large Icon itself as the preview image. Because that will save me the work of grabbing an appropriate frame from the video file since Windows is doing that job pretty well already. Any code snippet to access this Shell Icon image data?

推荐答案

当使用 Windows API 代码包,你可以这样做:

When using the Windows API Code Pack, you can do:

XAML

 <Image x:Name="img" />

C#

 img.Source = ShellFile.FromFilePath(@"C:\path\to\file.ext").Thumbnail.BitmapSource;

这需要添加 Microsoft-WindowsAPICodePack-Shell 包和适当的命名空间.

This requires adding the Microsoft-WindowsAPICodePack-Shell package and the appropriate namespaces.

这篇关于如何从我的 WPF 应用程序访问 Windows 文件预览图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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