如何使用SHgetfileinfo? [英] How to use SHgetfileinfo?

查看:68
本文介绍了如何使用SHgetfileinfo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SHGetfileinfo获取文件图标,这是我的代码

I use SHGetfileinfo to get icon of a file, this is my code

HIMAGELIST	hILSmall;  // handle of image list small
HIMAGELIST	hILLarge;  // handle of image list large

// create Image list.
hILSmall = ImageList_Create(CX_ICON_SMALL, CY_ICON_SMALL, FALSE, NUM_ICONS, 0);
hILLarge = ImageList_Create(CX_ICON_LARGE, CY_ICON_LARGE, FALSE, NUM_ICONS, 0);


::SHGetFileInfo(_T("E:\\v.doc"),0, &shfi, sizeof(shfi),SHGFI_SYSICONINDEX|SHGFI_SMALLICON);

HICON hIcon = LoadIcon(hInstance,shfi.iIcon);

ImageList_AddIcon(hILSmall, hIcon);
ImageList_AddIcon(hILLarge, hIcon);

int t = ImageList_GetImageCount(hILSmall);
int b = t;



但是,当我在b = t行中调试时,结果是t =0.:((谁能帮我?



But when i debug in line b = t, result is t = 0. :(( who can help me?

推荐答案

SHGetFileInfo将句柄返回到图标,所以在那里无需显式加载LoadIcon.

SHGetFileInfo return the handle to the icon so there is no need to LoadIcon explicitly.

HICON hIcon = ::SHGetFileInfo(_T("E:\\v.doc"),0, &shfi, sizeof(shfi),SHGFI_SYSICONINDEX|SHGFI_SMALLICON);
ImageList_AddIcon(hILSmall, hIcon);
int t = ImageList_GetImageCount(hILSmall);



-Saurabh



-Saurabh


这篇关于如何使用SHgetfileinfo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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