0

I want to set the project icon (the one that goes in the manifest and represents the EXE compiled as it's icon) from the Shell32.dll icon library.

I found this article on StackOverflow about "How can I use the images within shell32.dll in my C# project?" but it only shows how to load the icon as a Form Icon. I'd like to have it as the project icon, once it compiles. Reference even, instead of embeded as resource (if possible).

So my question is: is it possible to do?

SammuelMiranda
  • 420
  • 4
  • 29
  • 1
    Set the icon in the project property window: https://i.stack.imgur.com/Ho5Vu.png – stuartd Apr 25 '19 at 13:13
  • 1
    The icon of exe must be physically present in this exe as resource. You can't *link* system icon, but you can extract it and assign as usual either using a tool or by writing few lines of code. – Sinatr Apr 25 '19 at 14:28
  • Before you post, summarize the problem and provide details and example for that to describe what you’ve tried. – Hakimeh Mordadi Jul 28 '20 at 20:24

1 Answers1

-1

The main form is still a form and can be manipulated in the same way.

Assuming you use the IconExtractor class from the article you link to, you can do something like this:

public partial class Main : Form
{
    private Icon extractedIcon;

    public Main()
    {
        extractedIcon= IconExtractor.Extract("shell32.dll", 24, true);
        InitializeComponent();
        this.Icon = extractedIcon;
    }
}
Fabo.sk
  • 116
  • 1
  • 10
  • He asks about the project icon (eg icon of the application) not the form (which he already knows how to do, based on his referenced article). – Styxxy Apr 25 '19 at 13:34
  • Correct @Styxxy, i know how to get the icons from the DLL and put on the form (or anything else) once the program is already running; "Fabo.sk" my point is to set the icon of the program as it will show on the Explorer (the icon for the EXE file) refering to the dll icon (if possible) instead of embeding it as a resource. – SammuelMiranda Apr 25 '19 at 17:24
  • in that case @Sinatr is right in his comment, the icon must be present at compile time. – Fabo.sk Apr 25 '19 at 17:27
  • i believe it really can't be done - i could extract the icon from a DLL (using a function as this) save as a icon file and use as project icon - i will not do that because probably it's a violation of Windows EULA, maybe? Anyway, really found nothing online on how to not embed the icon and use as "a reference" to a DLL instead, sounds wrong to do it anyway. – SammuelMiranda Apr 26 '19 at 18:15