My company has a branding mechanism that sets the icon for a Windows Application, like so:
if (AppBranding.Is("FOO"))
Icon = MyProject.Properties.Resources.Icon_FOO;
else
Icon = MyProject.Properties.Resources.Icon_BAR;
Icon_FOO
and Icon_BAR
are resources that point to their respective .ico files.
Also, Icon and manifest in Project > MyProject Properties > Resources is set in Visual Studio.
When users launch the application, the correct icon appears based on branding. However, if they pin the program to the taskbar, the icon reverts to Icon_FOO.ico, regardless of branding. When they unpin it, the icon toggles back.
I believe that programs pinned to the taskbar use the icon of the .exe, while the icon for the Window is whatever I set Form.Icon
to be. I only know how to set the .exe icon by going to Project Properties > Resources and making a selection from the drop down list, as I have in the picture above. How can the icon for the .exe be set dynamically?
The icon in the taskbar is (usually) the first icon resource available in the assembly, and cannot be modified from within the application (unless you create a custom shortcut programmatically).
Instead of trying to manipulate this, you can create a simple starter application (*.exe) with the correct icon and version attributes for each branded version? The .exe than only needs to load the application from an assembly that contains the actual application content.
so you have
Launcher_FOO.exe
Launcher_BAR.exe
with their own custom icons. Both application will create a common application from
Actual_Application.dll
to start the application.
You may use Reflection.Emit
to create the Launcher_xxx.exe on the fly:
see google search
see msdn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With