SAMPLE: WinRes.exe Extracts an Icon from a Windows .EXE File

ID: Q70073

The information in this article applies to:

SUMMARY

WinRes.exe is a sample file that provides the necessary structures to extract an icon from a Windows .exe file.

NOTE: In Windows version 3.1 there is a new function named ExtractIcon() in SHELL.DLL that performs this type of functionality. However, this article and sample still provide a useful example of extracting .EXE file information.

MORE INFORMATION

The following file is available for download from the Microsoft Software Library:

 ~ WinRes.exe (size: 30738 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

MORE INFORMATION

The following is a list of the files in the WINRES archive and how each is used:

   Filename     Description
   ------------------------------------------------------------------------

   WINRES.C     Application to extract .ICO and .EXE resource
                information

   WINOPEN.C    Used to display FileOpen dialog box and retrieve the
                filename

   DUMPRES.H    .EXE header information derived from the "MS-DOS
                Encyclopedia" (Microsoft Press)

Program Theory of Operation

To retrieve the icons from an .ICO or .EXE file, the program must retrieve the device independent bitmaps (DIBs) that make up the icon. Although this is a difficult process, the necessary information is documented in the "MS- DOS Encyclopedia." A comment with each structure in the DUMPRES.H file provides a cross-reference to the relevant information in the "MS-DOS Encyclopedia." The .ICO file format is documented in Chapter 9, "File Formats," in version 3.0 of the "Microsoft Windows Software Development Kit Reference Volume 2."

Potential Enhancements to the Code

1. Choosing the Display Info menu item provides a listing of resource

   information about all resources in the file. This information
   should be placed into a list box, therefore the user will be able
   to scroll through the list. Currently, the information sometimes
   scrolls off the screen.

2. Pressing the I key on the keyboard will display the TEST.ICO file.
   Currently, this filename cannot be changed.

3. This version of the program does not support Windows 2.x .EXE
   files.

Differences Between .ICO Files and .EXE Resources

There are only three differences between an icon in an .ICO file and one in an .EXE file:

Additional query words: Keywords : kbfile kbsample kbIcon kbResource kbGrpUser kbWinOS310 kbWinOS300

Last Reviewed: December 24, 1998