问题描述
我试图通过在C#中使用此代码来获取指定路径中每个文件的默认缩略图:
SHFILEINFO shinfo = new SHFILEINFO();
IntPtr ptr = Win32.SHGetFileInfo(filename,0,ref shinfo,(uint)Marshal.SizeOf(shinfo),Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON);
图标图标= Icon.FromHandle(shinfo.hIcon);
MemoryStream ms = new MemoryStream();
icon.Save(ms);
BitmapDecoder decoder = IconBitmapDecoder.Create(ms,BitmapCreateOptions.None,BitmapCacheOption.None);
BitmapSource src = decoder.Frames [0];
它适用于所有文件类型Windows XP和Windows 7操作系统中的(视频,照片,音乐,其他文件),但在Windo中的视频,照片和音乐的文件类型无效(它显示为不受支持的图标图像) ws 8.
请帮我完成这项任务。
谢谢,
Hi,
I am trying to get default thumbnail image of every files from specified path by using this code in C# :
SHFILEINFO shinfo = new SHFILEINFO();
IntPtr ptr = Win32.SHGetFileInfo(filename, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON);
Icon icon = Icon.FromHandle(shinfo.hIcon);
MemoryStream ms = new MemoryStream();
icon.Save(ms);
BitmapDecoder decoder = IconBitmapDecoder.Create(ms, BitmapCreateOptions.None, BitmapCacheOption.None);
BitmapSource src = decoder.Frames[0];
It is working fine for all file types(Videos,Photos,Music,Other files) in Windows XP and Windows 7 OS , but not working(it is showing as unsupported icon image) for the file type of Videos,Photos and Music in Windows 8.
Please help me out of this task.
Thanks,
推荐答案
这篇关于使用SHGetFileInfo()c#获取Windows 8中的照片,音乐和视频类型的默认缩略图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!