How to perform "shell" icon embedding in Visual Studio 2010?
Asked Answered
T

2

4

As far as I can tell, there have been (at least?) three types of icon embedding. There's the original style used by shell32.dll and friends, .NET's embedding, and the new type that WPF uses. I'm looking for how to perform the first one, as I want to have a few other icons available as resources for a jumplist, which can only accept that style. However, I can't figure out how to embed in this style, only the other two.

How do I do this? All the results I find on google, etc are for adding icons to ResX files or similar.

Trichloroethylene answered 7/6, 2010 at 20:59 Comment(0)
R
4

I never heard the term "icon embedding" before. If you are talking about the icon that's visible for a EXE or DLL in Explorer or a desktop shortcut: that's done the same way for any Windows program. Both WF and WPF give the assembly an unmanaged resource with the selected icon using the /win32res compile option. You can see it in Visual Studio with File + Open + File, select the EXE or DLL.

To create a .res file, first create a .rc file. You can create one with the C++ IDE. Right-click the solution, Add New Project, Visual C++, Win32, Win32 Console Application. Right-click the Resource Files folder, Add + Resource, select Icon, Import. select your file. Repeat as needed. After you build, you'll get a .res file in the project's Debug build directory.

Back to your C# project, Project + Properties, Application tab. Select the Resource File option and navigate to the .res file.

Reichsmark answered 7/6, 2010 at 21:31 Comment(1)
Forgive me if my terminology isn't correct, not knowing what to search for is part of the problem. I can see the application's own icon by opening the assembly in VS as you describe, and this is what I'm talking about; however, I want to know how to add additional icons here automatically during the build process.Trichloroethylene
Y
3

I'd highly recommend taking a look at this solution posted here (http://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/). It integrates right into a ms build post build event and doesn't require an unmanaged project (to create an assembly from a .rc/.res file).

This removes a dependency on managing a second solution / assembly anytime you want update an icon and saves you from IL Merging the compiled c++ assembly.

I'd also recommend taking a look at WIX for your deployment. I've written a guide that accompanies this answer located here.

Ylla answered 2/5, 2012 at 14:36 Comment(1)
That was a very helpful post for adding icons to a JumpList icon.Cry

© 2022 - 2024 — McMap. All rights reserved.