I am trying to set a program's icon though the use of the this->icon statement. However, this only sets the program's icon in the title bar of the program, and doesn't set the icon for the executable itself. Is there a way to set the icon for the executable as well as the title bar
Thanks.
ps, I am using c++ 2005 express, and I am programming a managed app, but not using a windows forms application project.

Setting a Program Icon
Olivier B.
Hi,
Thanks for the help above.
Is there any way I can change the icon for an executable programmatically
I wish to change the icon for my executable depending on whether my game has a saved game file existing or not.
Is this possible to change the icon for my executable during run-time so that when the application exits, a different icon for my executable shows up in "windows explorer" or a "directory window"
Thanks.
Max
Morcollo
That's probably because your code is changing the icon for the in-memory copy of your program but isn't modifying the exe file.
At build-time it is relatively straightforward. If you look in your project folder, you should see a file called app.ico and another file called app.rc. The app.ico file is used by the compiler to generate your program's icon. The app.rc file is the input to the compiler that tells it to use app.ico (amongst other things).
You can either replace the contents of the app.ico file, or change the name of the file the compiler uses.
To replace the contents, rename app.ico to app.ico.original and then copy your icon file as app.ico. Rebuild your project and you should find that your exe file's icon has changed.
Alternatively, copy your icon file to your project fodler but don't change its name. Then, open app.rc using Notepad and find the line that looks like this
and change "app.ico" to the name of your icon file (be careful not to change anything else). Rebuild your project and again you should find your exe file is now using the new icon.
In most version of Visual Studio you could edit the ico file or the rc file directly from within the IDE but Express doesn't allow you to run the Resource Editor. you can edit the RC file as text by right-clicking on it and using "Open With" to open it with the the text editor instead of the resource editor.
sunnyluo
Thanks
My project didn't have the app.ico, or app.rc files, but i was able to copy them off of another project. The icon is now changed in the executable.