HINSTANCE hi; WORD pi=0; HICON ic=ExtractAssociatedIcon(hi,path.utf16(),&pi);
QPixmap* MainDialog::getFileSystemObjectIcon(const QString& fsObjectName, int sizeRead, int sizeReturn){ WORD w; HICON hi = ExtractAssociatedIconA(0, (LPSTR)fsObjectName.ascii(), &w); QPixmap *p = new QPixmap(sizeRead, sizeRead); if ((int)hi != -1) { QPainter pnt(p); HDC hdc = pnt.handle(); DrawIconEx(hdc, 0, 0, hi, sizeRead, sizeRead, 0, NULL, DI_IMAGE); pnt.end(); QBitmap bmp(sizeRead, sizeRead); pnt.begin(&bmp); hdc = pnt.handle(); DrawIconEx(hdc, 0, 0, hi, sizeRead, sizeRead, 0, NULL, DI_MASK); pnt.end(); p->setMask(bmp); DestroyIcon(hi); } if (sizeRead == sizeReturn || sizeReturn <= 0) return p; QImage im = p->convertToImage().smoothScale(sizeReturn, sizeReturn); p->convertFromImage(im); return p;}
WORD w;HICON ic=ExtractAssociatedIcon(0,(WCHAR*)path.unicode(),&w);ICONINFO info;GetIconInfo(ic,&info);QPixmap pix=QPixmap::fromWinHBITMAP(info.hbmColor,QPixmap::NoAlpha);