Found another solution, though I'm still interested in an answer on the above question. The other solution is to pass other constants to the SHGetFileInfo(..) method so that the method retrieves icons corresponding to fileextension, and not from the file itself. I'll just post it incase someone else is having the same problems: In Win32
public const uint SHGFI_ICON = 0x100;
public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
public const uint SHGFI_USEFILEATTRIBUTES = 0x10;
public const uint FILE_ATTRIBUTE_NORMAL = 0x80;
public const uint SHGFI_TYPENAME = 0x400;
In myClass
hImgSmall = Win32.SHGetFileInfo(
strAnyfilename, //this can even be a string to a nonexiting file
Win32.FILE_ATTRIBUTE_NORMAL,
ref shinfo,
(uint)Marshal.SizeOf(shinfo),
Win32.SHGFI_USEFILEATTRIBUTES |
Win32.SHGFI_TYPENAME |
Win32.SHGFI_ICON |
Win32.SHGFI_SMALLICON);
-Larantz- -- modified at 6:55 Wednesday 31st May, 2006