Windows actually determines the icon for a particular executable by using the first available icon resource in a compiled binary file. When making a shortcut in Windows, you have the option of choosing the icon. To see what icons live inside of a compiled binary, you can create a generic shortcut, and then load an exe, or dll file into the dialog when it asks where to look for the icon. A lot of executables have plenty unused icons that were just compiled in there because the coders were too lazy to strip their extra resources. This is a really simple procedure. Typically on the Macintosh platform, resource bloat is easier to spot, because the resource fork of an executable file is easier to open up and spy through. A windows exe has a little harder structure, and is not scrutinized so heavily.

Usually, you'd edit the icon in something really simple (I usually use Visual Studio's built-in resource script editor, but there are better ways to accomplish this). There are several third party applications that allow you to convert a bitmap into a .ico file, which then can be loaded, compiled, etc.

To give a particular window an icon, all you need to do is have the hIcon parameter of WNDCLASS, or WNDCLASSEX set to an HICON loaded from a resource script in the project:



(...blah..fill out the WNDCLASSEX structure)


This will place the resource located at the ordinal defined in your resource.h into the window. You can change it after the window is drawn, but that requires you to jump through a few more hoops.