Please tell me how to load an icon from an icon library in a dll file.
Thanks.
Printable View
Please tell me how to load an icon from an icon library in a dll file.
Thanks.
See ExtractIcon() and ExtractIconEx() win32 API. These are easily interopted to give you this functionality.
You can use it like:
Hope this helps.Code://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));
Regards.
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.