SHFILEINFO fileInfo;
SHGetFileInfo(szFileName,FILE_ATTRIBUTE_DIRECTORY,&fileInfo,sizeof(fileInfo), SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ICON | SHGFI_LARGEICON | SHGFI_SYSICONINDEX);
这里我去获取文件夹的图标,但是SHGFI_LARGEICON只能获取到32*32的图标,怎样才能获取到48*48的图标呢?
有人说使用SHGetImageList()函数,但是我在用VC++6.0编程的时候,发现没有这个函数。
请各位达人帮忙解决下,谢谢!

解决方案 »

  1.   

    icon图标制作倒是有现成的小软件。
      

  2.   

    SHGetImageList Function--------------------------------------------------------------------------------Retrieves an image list.SyntaxHRESULT SHGetImageList(          int iImageList,
        REFIID riid,
        void **ppv
    );
    ParametersiImageList
    [in] Value of type int that specifies the image type. It can be one of the following:
    SHIL_LARGE
    Under normal conditions, the image is 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the Appearance tab in the Display Properties, the image is 48x48 pixels.
    SHIL_SMALL
    The image is 16x16 pixels.
    SHIL_EXTRALARGE
    The image is larger than 32x32.
    SHIL_SYSSMALL
    The image tracks the system small icon metric.
    SHIL_LAST
    Specifies a convenience constant equal to the last constant, SHIL_SYSSMALL.
    riid
    [in] Image list interface identifier (IID_IImageList).
    ppv
    [out] Address of a pointer to an IImageList interface.
    Return ValueReturns S_OK if successful, or an error value otherwise. ResSHGetImageList is not exported by name from Shell32.dll. Use LoadLibrary to load Shell32.dll and GetProcAddress to access SHGetImageList at ordinal 727.The IImageList pointer type, such as that returned in ppv, can be cast as an HIMAGELIST as needed, for example for use in a list view. Reciprocally, an HIMAGELIST can be cast as a pointer to an IImageList.Function InformationMinimum DLL Version shell32.dll 
    Custom Implementation No 
    Header shellapi.h 
    Import library None 
    Minimum operating systems Windows XP 
      

  3.   

    你一定要48*48的 可以将获得的图标从32*32转化为48*48//  缩放图片
    void CShowIconDlg::ScaleBitmap(CBitmap *pBitmap,CBitmap &BitmapNew, int nWidth,int nHeight)
    {
    CDC dcSrc,dcDst ;
    int nWidthOld, nHeightOld ;
    int nWidthNew, nHeightNew ; BOOL bBitBlt;
    BITMAP    pBitMap ;
    pBitmap->GetBitmap(&pBitMap); nWidthOld       = pBitMap.bmWidth ;
    nHeightOld   = pBitMap.bmHeight ;
    nWidthNew  = nWidth ;
    nHeightNew = nHeight ; // Create DC
    dcSrc.CreateCompatibleDC((CDC*)NULL);
    dcDst.CreateCompatibleDC((CDC*)NULL); // Source Bitmap
    dcSrc.SelectObject(pBitmap); // New Bitmap
    BitmapNew.CreateCompatibleBitmap(&dcSrc,nWidthNew,nHeightNew); // Scale Bitmap
    dcDst.SelectObject(&BitmapNew);
    //Maps pixels from the source rectangle into blocks of pixels 
    //in the destination rectangle. The average color over 
    //the destination block of pixels approximates the color of the source 
    dcDst.SetStretchBltMode(HALFTONE) ; if(nWidthNew > nWidthOld)
    nWidthNew = nWidthOld;

    if(nHeightNew > nHeightOld)
    nHeightNew = nHeightOld; dcDst.StretchBlt((nWidth - nWidthNew) / 2, (nHeight - nHeightNew) / 2, nWidthNew, nHeightNew, &dcSrc, 0, 0, nWidthOld, nHeightOld, SRCCOPY);
    // Free Resource
    dcSrc.DeleteDC() ;
    dcDst.DeleteDC() ;
    }
    这个函数就用这个功能
      

  4.   

    我用MSDN能查到,关键是怎么使用,我用VC++6.0使用这个函数的时候,编译不过去,还有他的参数如何使用呀?
      

  5.   

    试试这里的C#代码.要包含<shellapi.h>.
      

  6.   

    http://pogopixels.com/blog/getting-the-48x48-or-256x256-icon-of-a-file-on-windows/
      

  7.   

    其实转化只是一个内存拷贝, 你可以用GDI画, 不会失真。 我试过了。
      

  8.   

    您好,你所用的是CBitmap,但是SHFILEINFO里的成员变量是HIcon,如何把HIcon转换成CBitmap呢?
      

  9.   

    IMAGEINFO   info; 
    BOOL   bOK   =   pImageList-> GetImageInfo(nImage,   &info); 
    if   (!bOK) 
            return;   //   ERROR CBitmap*   pTempBitmap   =   FromHandle(info.hbmImage);