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编程的时候,发现没有这个函数。
请各位达人帮忙解决下,谢谢!
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编程的时候,发现没有这个函数。
请各位达人帮忙解决下,谢谢!
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
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() ;
}
这个函数就用这个功能
BOOL bOK = pImageList-> GetImageInfo(nImage, &info);
if (!bOK)
return; // ERROR CBitmap* pTempBitmap = FromHandle(info.hbmImage);