Click to See Complete Forum and Search --> : help: Load icon from DLL


sstainba
July 16th, 2005, 12:03 AM
Please tell me how to load an icon from an icon library in a dll file.

Thanks.

SouthernCodeMonkey
July 16th, 2005, 01:43 AM
See ExtractIcon() and ExtractIconEx() win32 API. These are easily interopted to give you this functionality.

You can use it like:

//interopt declaration
[DllImport("shell32.dll")]
static extern IntPtr ExtractIcon(IntPtr hInst, string Filename, int IconIndex);
//in your code somewhere...where "this" is in reference to your main form.
Icon myIcon = Icon.FromHandle(ExtractIcon(this.Handle, "somelib.dll", 0));

Hope this helps.

Regards.

SouthernCodeMonkey
July 17th, 2005, 01:08 AM
Greetings.

I have created a sample project that implements a class that does the above described.

Feel free to offer feedback on this.

Regards.

P.S. The readme is from the artist that created the icon that is used in the project, not me.