Vista 256x256 compressed icons with VS 2005

November 20, 2006 15:30 by docbliny 

OK, today's teaser: How do you get the new 256x256 icons to work in a .NET application with Visual Studio 2005?

Here's the answer:

  1. Download ReplaceVistaIcon from CodeGuru.
  2. Set the application icon to "(Default Icon)" in the project properties / Resources / Icon. 
  3. Set the Build Action for the icon to "None". This will let you keep the actual file in the project.
  4. Add the following to a post build event (and modify any paths to match your system). You can omit the second line if you are not signing your assembly.
  • C:\Util\ReplaceVistaIcon.exe "$(TargetPath)" "$(ProjectDir)\IconVista.ico"
  • "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\SN" -R "$(TargetPath)" "$(ProjectDir)\MyKey.snk"

If you have other icons with a Build Action of "Resource" you will need to find out what the application icon ID is and append that to the first line. One way to dig this up is to use Visual Studio:

  1. Click on the File menu, and then click Open, and then click File....
  2. Browse to your compiled file.
  3. Expand [MyApplication.exe], and then expand Icon.
  4. Write down the number in front of the first icon.

All of this assumes that you have an icon editor that can actually create icons with 256x256 compressed PNG images. The reason you need to do this is because the .ico file format is a little "hacked" for Vista to maintain compatibility with Windows XP.

Add comment

  Country flag

  • Comment
  • Preview