[2.0] Reading Icons within C#
How could I read the application icon and extract it from another application to use it as icon or any other image format or drawing it in a picture box within the calling application. If there could I read a specific size for the icon or read all and use one size into another tool. I mean could I read all the sizes of the icon and can I use them separately in my application?
Re: [2.0] Reading Icons within C#
Why would you need to read the icon from another application?
Re: [2.0] Reading Icons within C#
I'd like to make an application to run another applications by callig them with shell and I want to make it dynamic to have the shortcuts for the other applications with thier icons to be clearly to the users, so the number and the application itself I don't know and they can modify at any time so I need to read the applications icons to show to the user to select from.
Re: [2.0] Reading Icons within C#
If you just want to get the icon, you can use the ExtractAssociatedIcon method:
Code:
System.Drawing.Icon oIcon = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Program files\Microsoft Office\Office12\winword.exe");
button1.Image = oIcon.ToBitmap();
oIcon = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Windows\system32\calc.exe");
button2.Image = oIcon.ToBitmap();
Re: [2.0] Reading Icons within C#
Thanks Negative it works but is there any other way to read a specific size for the Icon like 16X16, 23X23... etc. I tried your sample and it reads the size 32X32 only.
Re: [2.0] Reading Icons within C#
You could try this code from the Codebank, I haven't looked at it, but it appears to use the API:
http://www.vbforums.com/showthread.php?t=330985