What is a better practice for extracting icons?
I have created an explorer window that scans the directories upon loading for filetypes, etc. when it first loads, i use
internal static extern uint ExtractIconEx(string szFileName, uint nIconIndex, IntPtr[] phiconLarge, Int开发者_StackOverflow中文版Ptr[] phiconSmall, uint nIcons);
and
internal static unsafe extern int DestroyIcon(IntPtr hIcon);
to scan for currently registered icons and then i associate them with teh files im using. it works fine on my machine but when i run it on others, i get a low resource error. so my question is what is a better practice? to go the way that i am, and load them all up, or everytime i need to enumerate a directory to look for the filetype and associate it.
As an alternative you could do this with system.drawing
var icon = System.Drawing.Icon.ExtractAssociatedIcon(@"c:\xxx\some.file");
(You would need to resize this for the small shell size)
精彩评论