Retrieving correct indexed icon from iconfiles / exefiles
-
Hi everyone. Still working on my CustomGridColumnStyle class. So far I'm traversing the registry correctly, and I retrieve the correct exe-file or dll-file that contains icons for a specific filetype. Only problem is that for instance the icons for .txt files is located in shell32.dll at index -152, or atleast I believe it's index -152 due to registryvalue: "%SystemRoot%\system32\shell32.dll,-152" in subkey: "DefaultIcon", and I'm not pointing to that index so I just get the icon for dll-files when I display the txt-files... For extracting the icon I use Win32.SHGetFileInfo(..), and I'm wondering: Is there any way of specifying which icon you want extraced? By index perhaps?
hImgSmall = Win32.SHGetFileInfo(filePath, 0, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
Win32.SHGFI_ICON |
Win32.SHGFI_SMALLICON);I think the Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON points to some kind of index though. If anyone has any knowledge of Win32.SHGetFileInfo I'd really appreciate some feedback. -Larantz-
-
Hi everyone. Still working on my CustomGridColumnStyle class. So far I'm traversing the registry correctly, and I retrieve the correct exe-file or dll-file that contains icons for a specific filetype. Only problem is that for instance the icons for .txt files is located in shell32.dll at index -152, or atleast I believe it's index -152 due to registryvalue: "%SystemRoot%\system32\shell32.dll,-152" in subkey: "DefaultIcon", and I'm not pointing to that index so I just get the icon for dll-files when I display the txt-files... For extracting the icon I use Win32.SHGetFileInfo(..), and I'm wondering: Is there any way of specifying which icon you want extraced? By index perhaps?
hImgSmall = Win32.SHGetFileInfo(filePath, 0, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
Win32.SHGFI_ICON |
Win32.SHGFI_SMALLICON);I think the Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON points to some kind of index though. If anyone has any knowledge of Win32.SHGetFileInfo I'd really appreciate some feedback. -Larantz-
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