Include icons in .net exe file

Hi,
I am trying to include icons in my .net exe so that I can select those icons for the shell, like setting the icons of shortcuts, icons for some file types, etc...

I tried to include the icons in the Resource files, with different 'Persistance' property set, added icons directly to the solutions with different 'Build Action' property set.

But the only icon that appears in the exe file, when I try to select an icon through the windows explorer is the one that I selected for the application from the project properties.

Please advice.

Regards,
Ashutosh
LVL 6
ashutosh_kumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ShazbotOKCommented:
You can add images as a embedded resource by going to Project properties --> Resources --> Add --> Existing File.

Once added you can reference the image under the Resources namespace.
0
ashutosh_kumarAuthor Commented:
shazbotOK, I understand what you are saying. But thats now what I want.

Actually, I got my answer from the Microsoft's forum....

-
Ashutosh
MCTS - .net 2.0 Win Apps
0
ashutosh_kumarAuthor Commented:
The solution
--------------

   You have to place the icons in a Win32 resource file (you create it with the Resource Compiler).  You then have to modify the CSPROJ file to include the /win32res flag on the CSC task to point to your Win32 resource file (through the Win32Resource attribute) or you can manually compile your project on the command line and use this flag.

   If you want to specify an icon for your assembly, then you have to use the /win32icon switch, and point to a icon file.

   The documentation for CSC (the executable and task in MSBUILD) has more information.


--
- Nicholas Paldino [.NET/C# MVP]
----------------------------------------------------------------------------
Hi Nicholas,
Thanks for your response.

I have created a resource file in Visual C++ 6.0 editor and have also
compiled it to .res file. However, I don't want to compile the project from
the command line every time. So, can you please assist me where should I put
the 'win32res' flag as C# doesn't provide a GUI as C++ to change/add
compiler options.

Regards,
Ashutosh

----------------------------------------------------

Hi Ashutosh,

If you're using VS 2005, you can embed the Win32 resource file in the C#
project through the Project Designer.

In detail:
1. Right click the project item in the Solution Explorer and choose
Properties.
2. In the Project Designer, switch to the Application tab.
3. Select the option 'Resource File' in the Resources group and click the
button on the right to browse to your Win32 resource file.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShazbotOKCommented:
Soooo... am I to understand that you want to basically allow your Userbase to be able to change the Icon's within the display of the application?  as in simply referencing a image NOT compiled within the EXE/DLL ??
0
ashutosh_kumarAuthor Commented:
No, I wanted windows shell (explorer) to access icons in the exe, other than the one that is displayed as the exe's icons.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.