Times up!
I figured out the solution after reading an article on reading icons. You do it like so:-
Code:
//You need these... (not in standard Windows headers?)
#pragma pack( push )
#pragma pack( 2 )
typedef struct {
BYTE bWidth; // Width of the image
BYTE bHeight; // Height of the image (times 2)
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
BYTE bReserved; // Reserved
WORD wPlanes; // Color Planes
WORD wBitCount; // Bits per pixel
DWORD dwBytesInRes; // how many bytes in this resource?
WORD nID; // the ID
} MEMICONDIRENTRY, *LPMEMICONDIRENTRY;
typedef struct {
WORD idReserved; // Reserved
WORD idType; // resource type (1 for icons)
WORD idCount; // how many images?
MEMICONDIRENTRY idEntries[1]; // the entries for each image
} MEMICONDIR, *LPMEMICONDIR;
HGLOBAL res;
HICON icon = NULL;
HMODULE module;
HRSRC ressrc;
int i;
LPMEMICONDIR lpIconDir;
LPBYTE lpIconImage;
module = LoadLibraryEx("shell32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
ressrc = FindResource(module, MAKEINTRESOURCE(4), RT_GROUP_ICON);
res = LoadResource(module, ressrc);
lpIconDir = LockResource(res);
for (i=0;i<lpIconDir->idCount;i++)
if (lpIconDir->idEntries[i].wBitCount == 8 && lpIconDir->idEntries[i].bWidth == GetSystemMetrics(SM_CXSMICON))
{
ressrc = FindResource(module, MAKEINTRESOURCE(lpIconDir->idEntries[i].nID), RT_ICON);
res = LoadResource(module, ressrc);
lpIconImage = LockResource(res);
icon = CreateIconFromResourceEx(lpIconImage, SizeofResource(module, ressrc), TRUE, 0x00030000, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
break;
}
himl = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 1, 1);
ImageList_AddIcon(himl, icon);
DestroyIcon(icon);
Next step for me is getting a specific colour format of the icon the shell uses for folders (involves SHGetFileInfo)...