How To Create an Icon Extractor Utility

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”;

[DllImport(SHELL_32)]

static extern IntPtr ExtractIcon(IntPtr hInst, string lpszExeFileName, uint nIconIndex);

const string FILE_NAME = @”C:\Windows\notepad.exe”;

Icon icon;

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 Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , | Posted under 3rd Party Software, Programming/Coding | RSS 2.0

Leave a Reply

Your email address will not be published. Required fields are marked *


9 − 1 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>