ShGetFileInfo caused a weird directory

I have a simple file browser, and there I show files and folders,

received (for the catalog)

SHFILEINFO info = new SHFILEINFO();
SHGetFileInfo(filename,
FILE_ATTRIBUTE_DIRECTORY,
ref info,Marshal.SizeOf(info),
SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_ADDOVERLAYS);

It works 100% perfectly, but I noticed a strange thing - if I try to get an icon for a directory, but specify FILE_ATTRIBUTE_NORMAL instead of FILE_ATTRIBUTE_DIRECTORY but this is strange for directories - ordinary folders have "unknown file type" icons, the trash has a VLC icon, etc. Directories under SVN have their own overlay, but the main file icon (white sheet of paper).

I understand that the database icon for the directory will now be an unknown file, but why do some folders have a completely strange icon? Config.MSI has an installer icon, in the basket there is a VLC icon (wtf ?!), etc. What does the shell function do with these parameters? Exactly what badge does he get?

Again, this is not a problem, I'm just curious.

+3
source share
1 answer

As far as I know, icon resources access their numerical index, so I assume that the correct index is retrieved and the icon is then retrieved from the wrong library or from the right, but using the wrong offset + the correct index.

+1
source

Source: https://habr.com/ru/post/1737354/


All Articles