全局变量:
public:
CImageList m_ImageSmall;
CImageList m_ImageLarge;//////////////////////////////////////////////////////////////////////////////////////////////////////
构造函数里:
SHFILEINFO rInfo;
HIMAGELIST hImglist = (HIMAGELIST) SHGetFileInfo ( _T(""), 
                                                        0, 
                                                   &rInfo,
                                                   sizeof(SHFILEINFO), 
                                            SHGFI_ICON | SHGFI_SMALLICON |SHGFI_SYSICONINDEX );
m_ImageSmall.Attach ( hImglist );
SHFILEINFO rInfo2;
HIMAGELIST hImglist2 = (HIMAGELIST) SHGetFileInfo ( _T(""),
                                                         0,
                                                   &rInfo2,
                                        sizeof(SHFILEINFO),                                SHGFI_ICON |SHGFI_LARGEICON|SHGFI_SYSICONINDEX );
m_ImageLarge.Attach ( hImglist2 );//////////////////////////////////////////////////////////////////////////////////////////////////////
析构函数里:
m_ImageSmall.Detach();
m_ImageLarge.Detach();

解决方案 »

  1.   

    应该没有吧用boundchecker检查一下
      

  2.   

    If SHGetFileInfo returns an icon handle in the hIcon member of the SHFILEINFO structure pointed to by psfi, you are responsible for freeing it with DestroyIcon when you no longer need it.Note  Once you have a handle to a system image list, you can use the Image List API to manipulate it like any other image list. Because system image lists are created on a per-process basis, you should treat them as read-only objects. Writing to a system image list may overwrite or delete one of the system images, making it unavailable or incorrect for the remainder of the process.
      

  3.   

    有的
    rInfo里面的hIcon要用DestroyIcon删掉,否则会内存泄漏