hmm. that does not seem to work. when I try it there is no icon added, there is no image added at all. here is my code for that section (almost identical to that on the blog entry at the link anonytmouse posted):
Code:
SHFILEINFO sfi;
HIMAGELIST himl;
hFile = CreateFile(szFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
return FALSE;
else
CloseHandle(hFile);
himl = (HIMAGELIST)SHGetFileInfo(szFile, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_LARGEICON);
if(!himl)
return FALSE;
ListView_SetImageList(hwndList, himl, LVSIL_NORMAL);
lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
lvItem.cchTextMax = MAX_PATH;
lvItem.iItem = iIndex;
lvItem.iImage = sfi.iIcon;
lvItem.iSubItem = 0;
lvItem.pszText = szFile;
ListView_InsertItem(hwndList, &lvItem);
those first 2 structs are obviously declared with the set of local variables at the beginning of the dialog's callback function, I just added them here to show that nothing was wrong with them and they aren't being used for anything else. excuse the formatting, it got screwed up when I copy and pasted it here. and the listview control is created with the LVS_SHAREIMAGELISTS attribute. iIndex is an int that is incremented everytime an item is successfully added, and decremented every time one is removed (just to keep the items in the same order as they are added, also to keep track of the amount of items in the listview at all times), and szFile is the path to the file (obviously a valid file). the text gets added fine but the icon doesn't.
could anyone please tell me why this isn't working? thank you in advance.