I have been studying the code in the Win32wsshellctrls and I don't think the use of the ListView_GetImageList and set_ImageList is correct?
In code, the list view image list is created when it is detected that it does not exists, so the current image index that was returned from the system per current filename introduced will trigger a creation of the list, and add that one image from the system image handle to it.
But I only see one image being added so something is strange here.
Normally you create an image list, add all the images to that list while enumerating, free each handle as you go, and in the end, assign that image list to the ListView_SetImageList and now you have an attached list.
On top of that, when refreshing the list via a different ext for example, I don't think that list ever gets reloaded with new icons, because it already exists with the prior one, this can lead the list to not having the indexed item in it and do all sorts of nice things.
I would thing the list needs to be purged between refreshes.
Maybe I am overloading something, but this isn't working from what I can see.
Please look here at an C example.
https://learn.microsoft.com/en-us/windows/win32/controls/add-list-view-image-listsJamie