IconReplace

Replaces an existing icon group with a new icon group.

Syntax:

IconReplace(filename, icon filename [, index [, flags]])

Parameters:

(s) filename either a fully qualified filename with drive and path, or just a filename and extension.

(s) icon filename the filename of the icon.

(i) index [optional] specifies the ordinal position of the icon group to modify, where the first icon group is 1.

(i) flags [optional] see below.

Returns:

(i) Number of icons replaced.

 

"flags" can be set to 0, or can specify one or more of the following values combined with the bitwise OR ('|') operator:

Value

Meaning

0

Default

1

Delete un-replaced icon images in the target icon group (32-bit EXE's only) (Windows NT and newer)

For example, if the target icon group in the EXE has 6 icon images, and the specified .ICO file has only one icon image, if you specify this flag then the one matching icon image in the EXE will be replaced and the other 5 will be deleted.

 

It is suggested that caution be used when using this command, keeping the following points in mind:

  1. The EXE file might become damaged and be unable to run. This is especially true of some programs that checksum themselves to verify the EXE. KEEP BACKUPS.

  2. System anti-virus tools might detect the alteration of an EXE file and complain. If this is true, then either the anti-virus program must be disabled, or another work around must be used. Some anti-virus programs allow the specification of a "trusted" program - the trusted feature may be used with due caution.

  3. The application whose icon is being modified must not be running while its EXE file is being modified.

Note: An icon group is a set of one or more associated icon images, of different dimensions and color depths. An EXE file can contain multiple icon groups; an icon (.ICO) file contains a single icon group.

Each icon image in the targeted icon group in the EXE file is compared with each icon image in the specified .ICO file, and if the .ICO file contains an icon image whose size (and dimensions and color depth) is the same as the targeted icon image in the EXE, then the targeted icon image in the EXE is replaced with the corresponding icon image from the .ICO file. If no suitable replacement icon is found in the .ICO file, then that particular icon image in the EXE is left unchanged.

 

Requirements for Icons

The .ICO file must have all the following image formats to successfully replace all the icons in the icon group.

 

Dimensions

Color Depth

16x16

4 bit color

16x16

8 bit color

16x16

32-bit color

32x32

4 bit color

32x32

8 bit color

32x32

32-bit color

48x48

4 bit color

48x48

8 bit color

48x48

32-bit color

 

Example:


IconReplace("FILENAME.EXE", "ICONFILE.ICO",1)
See Also:

IconExtract, IconInfo, IntControl 37