Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / Win32

Adding an icon file's icons to an executable

1.33/5 (2 votes)
24 Jul 2008CPOL1 min read 1   175  
A VS2008 C++ project to add an icon resource in a file to an executable.

Introduction

This VS2008 C++ project uses the STL and the Boost 1.35.0 library to produce a simple command line utility that takes the arguments of an icon file name, an executable file name, and optionally an integer in the range [1, 64K]. It then adds the icons in the icon file and adds them to the executable.

Background

This project came about as I had to add an icon resource to a product of a build which utilises the Qt qmake build system. As far as I could determine, this system does not allow for the required flexibility in assigning icon resources and versioning resources for a WinXP build. I initially solved my problem using batch files to parse rc files as a pre-link activity but after a post resource compilation. I decided that it was not very elegant and resolved to create a utility, to be used post-link, in my own time.

Information to achieve this simple goal is not very plentiful and what does exist is not concise.

Points of Interest

The C++ code uses STL file streams for getting the data out of the file and the boost::shared_array smart pointer for memory management.

Doxygen is used to provide the HTML documentation. Look for 'index.html' in the HTML bucket. It gives a nice way to explore the code.

I hope that this helps somebody!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)