Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
C++
hil = (HIMAGELIST)SHGetFileInfo( itemss, FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_ENCRYPTED|FILE_ATTRIBUTE_HIDDEN, &sfi, sizeof(sfi), SHGFI_USEFILEATTRIBUTES|SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_ICON);



I want to list files and directorys with the image icons. I can only get files. Or I can get only directorys. I know its something with the flags but can not figure it out. I checked documentary with the command and used all the flags but still does not work

If i just use FILE_ATTRIBUTE_DIRECTORY, than everything is a folder..even files like *.sys

If i just use FILE_ATTRIBUTE_ARCHIVE, then folders don't get listed.....

i looked in Winnt.h..nothing works
Posted
Updated 12-Jul-13 21:18pm
v4

1 solution

When using the SHGFI_USEFILEATTRIBUTES flag, the dwFileAttributes parameter specifies if the passed file name is a directory or a file. So you must pass the attribute of the specific file and not a combination of attributes.

I assume that you are using CFileFind or FindFirstFile() / FindNextFile() to get the file list. Then use the attributes provided by these functions or just FILE_ATTRIBUTE_DIRECTORY for directories and FILE_ATTRIBUTE_NORMAL for files.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900