Retrieve Associated Icon
Community Forums/General Help/Retrieve Associated Icon
| ||
Does anybody have a code snippet to get the associated icon from a file? In other words, I want to read a directory and get the associated icons for all of the files and display them like the Windows Explorer does. There is a wxFileType widget for this, but I do not believe it is wrapped by Brucey. Brucey, any chance that could happen? Thanks for any help? |
| ||
This seems to work -- in that it doesn't crash -- but it only gives you an icon handle:Extern "win32" Function ExtractAssociatedIconA (hInst, lpIconPath:Byte Ptr, lpiIcon:Byte Ptr) Function GetModuleHandleA (lpModuleName:Byte Ptr) End Extern iconpath$ = "C:\Windows\notepad.exe" ' Path to file from which icon should be extracted iconindex:Short = 0 ' Index number of icon within file (may contain multiple icons) exe = GetModuleHandleA (Null) icon = ExtractAssociatedIconA (exe, iconpath.ToCString (), Varptr iconindex) Print icon How to actually draw the icon returned is another matter, one I haven't been able to figure out... Last edited 2011 |
| ||
I got that far, but thanks. You are suppose to be able to get an HBitMap from an HIcon, but i haven't gone down that road yet. I am using wxMax in my project, and the wxWidgets has a wxFileType library that will do this exact thing, but Brucey hasn't wrapped that functionality. I am thinking about taking a shot at it, by looking at his other work, but I have never done that sort of thing before, so I probably won't be successful. |