Load Icon from dll in .NET

  • Thread starter Thread starter Leon
  • Start date Start date
L

Leon

Hi.

How to load an icon from a dll in .NET? I know using API ExtractIcon()
can
do this. Does .NET framework provide some classes for this purpose?


Best Regards
Leon
 
First, thanks for you reply!

What you said is load icon from a .ico file.

What I want to do it load icon resource from a dll file, for example,
C:\Winnt\System32\Shell32.dll.
the dll is a standard Win32 DLL, How I can load the icon in the dll?

Best Regards
Leon
 
Leon said:
Hi.

How to load an icon from a dll in .NET? I know using API ExtractIcon()
can
do this. Does .NET framework provide some classes for this purpose?


Best Regards
Leon

Yes.
First you need to add the icon file to the project and in
"Properties" Toolbar->"Build Action" property you need to set it as "Embedded Resource"
After that, in your code, you do the following:

Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("youricon"));

where "youricon" is in following format: "projectname.youricon.ico".

I am using it frequently and it works fine for me.
Please let me know if you still need some help on that!

Good Luck,
Andrey
 
Back
Top