您的位置:首页 > 其它

SHGetFileInfo的用法

2010-11-18 11:38 381 查看
函数原型:

WINSHELLAPI DWORD WINAPI SHGetFileInfo

(
LPCTSTR

pszPath

,
DWORD

dwFileAttributes

,
SHFILEINFO FAR

*psfi

,
UINT

cbFileInfo

,
UINT

uFlags

);

其中,当uFlags使用
SHGFI_ICON时,注意下面一段:

Retrieve the handle to the icon that represents the file and the index of the
icon within the system image list. The handle is copied to the hIcon

member of the structure specified by psfi
, and the index is copied to the
iIcon
member. The return value is the handle to the system image list.
You must call the DestroyIcon
function on this icon handle.

否则会造成内存泄露,SHGetFileInfo再使用时就获取不到图标.

遇到不解的问题,首先查MSDN...

另外,如果使用这个函数获取其它信息,比如文件类型,那么参数里就不要再使用

SHGFI_ICON,因为这样如果不注意,后面没有DestroyIcon,同样会引起图标消失的问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: