I'm looking for a way to take an icon from an executable, and create a new executable (using CSharpCodeProvider) that uses this icon.
The first part is easy, I do it using:
Icon icon = Icon.ExtractAssociatedIcon(path);
The problems come when I want to "attach" the icon. I tried using:
compilerParameters.CompilerOptions = @"/win32icon:"
But this solution requires the icon to be written in a file and I'd like to avoid that (one of the reason being it's such a mess to save an icon with more than 16 colors...).
Is it possible to use the System.Drawing.Icon object in memory directly?
EDIT: Just to be clear, I'm trying to obtain a code that can compile C# code into an executable. This executable will have an icon that is only hold in memory (as an Icon object) and not in a file (as a .ico file).