【发布时间】:2011-07-08 13:28:39
【问题描述】:
我正在使用 C#、Windows 窗体、Net 2.0。
我正在使用 SHGetImageList 来获取系统映像列表,比如 SHIL_JUMBO 参数,并在 Windows 7 上获取 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);
将系统图像列表设置为我的列表视图,并且
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;
}
获取列表视图中加载的不同文件/文件夹的图标索引。
一切正常,除了我得到了 256 个大图标,即使是电影或图像文件,我希望在其中有缩略图(图像/电影的预览),就像在 Windows 资源管理器中一样。
如何获取缩略图,而不是在 Windows 资源管理器中显示为缩略图的文件图标?
【问题讨论】:
标签: c# winforms shell listview native