|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to read all icons in a .ico fileHi all,
If I have a .ico file that contains mulitple icons, is there a way to construct System.Drawing.Icon objects from all of the images in the file? The Icon constructor does not provide an "index" argument to specify which icon to load into the Icon object. Same question for .exe and .dll files: Icon.ExtractAssociatedIcon presumably returns an Icon with a PE file's primary icon image (the documentation is very sketchy). If my PE file contains multiple icon resources, is there a way to enumerate them and extract the icons from them? TIA - Bob Hello Bob,
From your description, you're wantting to programmatically extract icon images(multiple) from a .ico file (or some other win32 resource file like exe or dll), right? Based on my research, for such cases that we need to load win32 resources from a certain resource image in .net framework code, the most common way is manually parse the ico file based on its file structure. For exe and dll, since there are existing win32 API to load and extract resource, you can use PInvoke to call some unmanaged API in your .net code. I have found the following two web articles which has provide some code on reading multipe icons from ico and other resource image: #Access multiple icons in a single icon file http://www.codeproject.com/dotnet/MultiIcon.asp #IconLib - Icons Unfolded (MultiIcon and Windows Vista supported) http://www.codeproject.com/useritems/IconLib.asp also, following is a project which originally created via VB and rewritten in C#, it is also quite a good example for your reference: #.NET Icon explorer http://www.vbaccelerator.com/home/NET/Utilities/Icon_Extractor/IconExplorer. asp Hope this helps you. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Way cool! Thanks Steven, that's exactly what I was looking for.
BTW, the link you gave for Icon Explorer doesn't work. Here's a better link: http://www.vbaccelerator.com/home/NET/Utilities/Icon_Extractor/article.asp Show quote "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:aVGLVolVHHA.416@TK2MSFTNGHUB02.phx.gbl... > Hello Bob, > > From your description, you're wantting to programmatically extract icon > images(multiple) from a .ico file (or some other win32 resource file like > exe or dll), right? > > Based on my research, for such cases that we need to load win32 resources > from a certain resource image in .net framework code, the most common way > is manually parse the ico file based on its file structure. For exe and > dll, since there are existing win32 API to load and extract resource, you > can use PInvoke to call some unmanaged API in your .net code. I have > found > the following two web articles which has provide some code on reading > multipe icons from ico and other resource image: > > #Access multiple icons in a single icon file > http://www.codeproject.com/dotnet/MultiIcon.asp > > #IconLib - Icons Unfolded (MultiIcon and Windows Vista supported) > http://www.codeproject.com/useritems/IconLib.asp > > also, following is a project which originally created via VB and rewritten > in C#, it is also quite a good example for your reference: > > #.NET Icon explorer > http://www.vbaccelerator.com/home/NET/Utilities/Icon_Extractor/IconExplorer. > asp > > Hope this helps you. > > Sincerely, > > Steven Cheng > > Microsoft MSDN Online Support Lead > > > > ================================================== > > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > > ================================================== > > > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > > > > Thanks for your reply Bob,
I'm glad the information helps you. Yes, the link to the Iconexplorer may be broke due to line break. Anyway, you can easily get it by searching ".net icon explorer" Have a nice day! Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights. |
|||||||||||||||||||||||