You, like I, have probably had to use tools to extract the icon from the *.exe or *.dll files. Have you ever wondered how difficult it is to make such a tool? I decided to deal with this issue in this example of extracting icons from the standard Notepad program.
public partial class Form1 : Form
const string SHELL_32 = “Shell32.dll”;
static extern IntPtr ExtractIcon(IntPtr hInst, string lpszExeFileName, uint nIconIndex);
const string FILE_NAME = @”C:\Windows\notepad.exe”;
private void Form1_Load(object sender, EventArgs e)
icon = Icon.FromHandle(ExtractIcon(Process.GetCurrentProcess().MainModule.BaseAddress, FILE_NAME, 0));
private void Form1_Paint(object sender, PaintEventArgs e)
e.Graphics.DrawIcon(icon, new Rectangle(32, 32, 32, 32));
As you can see, only several lines of code are actually needed to create an Icon Extractor utility 🙂
Looking for quality Silverlight HostingArvixe Web Hosting!