C#:使用SHGetImageList和SHGetFileInfo,如Windows资源管理器,获取文件的大缩略图/预览,而不是大图标

C#:使用SHGetImageList和SHGetFileInfo,如Windows资源管理器,获取文件的大缩略图/预览,而不是大图标,c#,winforms,shell,listview,native,C#,Winforms,Shell,Listview,Native,我正在使用C#,Windows窗体,NET2.0 我使用SHGetImageList获取系统映像列表,比如说,SHIL_JUMBO参数,并在Windows7上获取大的256x256映像 [DllImport(SHELL32, EntryPoint = "#727")] public static extern int SHGetImageList(int imageList, ref Guid riid, ref IntPtr handle); public static IntPtr Get

我正在使用C#,Windows窗体,NET2.0

我使用SHGetImageList获取系统映像列表,比如说,SHIL_JUMBO参数,并在Windows7上获取大的256x256映像

[DllImport(SHELL32, EntryPoint = "#727")]
public static extern int SHGetImageList(int imageList, ref Guid riid, ref IntPtr handle);

public static IntPtr Get(SystemImageListType type)
{
    IntPtr handle = IntPtr.Zero;
    NativeMethods.SHGetImageList((int)type, ref NativeMethods.IIDImageList, ref handle);
    return handle;
}
我也在使用

NativeMethods.SendMessage(listView.Handle, LVM_SETIMAGELIST, LVSIL_NORMAL, imageListHandle);
将系统映像列表设置为我的listview,以及

public static int GetFileIconIndex(string pathName)
{
    NativeMethods.SHFILEINFO shfiData = new NativeMethods.SHFILEINFO();

    NativeMethods.SHGetFileInfo(
        pathName,
        0,
        ref shfiData,
        Marshal.SizeOf(typeof(NativeMethods.SHFILEINFO)),
        NativeMethods.SHGFI.SYSICONINDEX |
        NativeMethods.SHGFI.LARGEICON |
        NativeMethods.SHGFI.ICON );
    return shfiData.iIcon;
}
获取listview中加载的不同文件/文件夹的图标索引

一切都很好,除了我得到大的256图标,即使是电影或图像文件,我会期待一个缩略图(预览图像/电影),如在Windows资源管理器


如何获取缩略图,而不是Windows资源管理器中显示为缩略图的文件的图标?

在Windows Vista及更高版本中,您可以使用该界面

这里面有一个包装器

对于XP,有不同的界面,请参见:

显然,您必须决定哪些文件将使用系统图像列表图标,哪些文件将使用缩略图