private void create() {
// forget last image list if any:
hIml = IntPtr.Zero;
if (isXpOrAbove()) {
// Get the System IImageList object from the Shell:
Guid iidImageList = new
Guid("46EB5926-582E-4017-9FDF-E8998DAA0950");
int ret = SHGetImageList(
(int)size,
ref iidImageList,
ref iImageList
);
// the image list handle is the IUnknown pointer, but
// using Marshal.GetIUnknownForObject doesn't return
// the right value. It really doesn't hurt to make
// a second call to get the handle:
SHGetImageListHandle((int)size, ref iidImageList, ref hIml);
}
else {
// Prepare flags:
var dwFlags = FIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES | FIcon.SHGetFileInfoConstants.SHGFI_SYSICONINDEX;
if (size == SysImageListSize.smallIcons) {
dwFlags |= FIcon.SHGetFileInfoConstants.SHGFI_SMALLICON;
}
// Get image list
var shfi = new BExplorer.Shell.Interop.SHFILEINFO();
uint shfiSize = (uint)Marshal.SizeOf(shfi.GetType());
// Call SHGetFileInfo to get the image list handle
// using an arbitrary file:
hIml = SHGetFileInfo(
".txt",
FILE_ATTRIBUTE_NORMAL,
ref shfi,
shfiSize,
(uint)dwFlags);
System.Diagnostics.Debug.Assert((hIml != IntPtr.Zero), "Failed tocreate Image List<>");
}
}