Custom Icons For Win32 Starpacks - The Real Story

Summary

Long story short: forget about most of the complicated (outdated) procedures below. Just use the tclkit.ico technique outlined more towards the end of this text and - important: create your own icon file with the common icon sizes (using a dedicated editor, e.g. IcoFX) and you're done, including the icon being shown in windows explorer.

Synopsis

There are TWO ways of embedding custom icons into a Starpack:

JCW's method only works with specially prepared Starpack runtimes. And the only such runtime that I know of is JCW's own tclkit.exe/tclkit-win32.upx.exe.

(And even then, though you'd expect JCW's method to work with his own specially prepared runtime, on my machine at least (Windows 95 OSR2 with ActiveState Tcl 8.4,) it DOESN'T. I have no idea why not.)

But even if you can get JCW's method to work with tclkit.exe/tclkit-win32.upx.exe, you can't always use that runtime. For example, if your application needs:

BLT
you'll have to use a Tclkit with BLT burnt into it. For example bikit.exe or dqkit-win32-i386-all.exe.
Tix
you'll need TixTclKit.exe (which is, as far as I know, the only Tclkit runtime with Tix).

JCW's article

The info given in Custom icons for win32 starpacks is DODGY! I can't correct that page itself, because it's not on the Wiki, and not editable. So click Custom Icons For Win32 Starpacks - The Real Story, if you want a method of customizing the icons in a Starpack that:-

  • Actually works,
  • Works with ANY RUNTIME (whether or not it's got a tclkit.ico in the tclkit's topdir), and;
  • Allows you to ADD any icons you want to the runtime - and DELETE any that you don't want - to get exactly the set of (zero or more) icons you want.

jcw: It would be nice if you (no name given) could please explain what does and does not work for you in the article. I'm also more than happy to explain how tclkit.ico can be used in any runtime (it's quite simple) if that's what you're after

Thanks jcw. My name's Peter Newman. The runtimes I want to use are BIKIT.EXE or DQKIT.EXE - cause I need BLT. Neither of those runtimes have that six icon tclkit.ico your method requires in the $starkit::topdir. So your method, as you've described it, won't work with these. But if there's a modified method that will, let me know.

Also, I couldn't get your method to work with TCLKIT-WIN32.UPX.EXE - a recent version which I downloaded a few weeks ago (early February 2004). But that might be my fault. I didn't try very hard - since it's BIKIT.EXE and DQKIT.EXE I want the icons for.

jcw: I've added some more details about how this is all supposed to work in SDX to the article

Description

Fortunately, the method described below will work with ANY (Windows) Tclkit runtime. In fact, it'll burn your own custom icons into ANY Windows EXE file - whether it's a Tclkit runtime or not.

Both methods are roughly the same - time and effort wise - to use. And they're both quite simple to use. Once you've grasped the concepts, both take only a few minutes to install your custom icons into the Starpack. So use whichever method suits (though the method described below is the only one which always works).

NOTE that the method described below is also a more ROBUST method. Since it uses the official Microsoft-defined methods for manipulating the icons in EXE files. OK, we're using third-party manufactured, freeware/open source tools rather than the Microsoft manufactured ones. But they should still be adding and deleting icons to/from the EXE file, using the Windows API calls, etc, provided for this purpose (well, at least I hope they do).

OK! Now I'll describe the method that always works...

So What's A Starpack?

A Starpack is wish and your Tcl scripts and supporting packages all wrapped up into a single Windows EXE file that the user can execute like any other Windows EXE file (and irrespective of whether or not they've got Tcl installed). But you're a Tcl programmer, so you already know that...

What Are Custom Icons?

Windows EXE files come with zero or more icons inside them. If the EXE file has no icons of its own, Windows just uses standard defaults. These icons (whether they're the EXE file's own, or the standard defaults,) appear:

  • In Windows Explorer, by the program's filespec.
  • On the Desktop or anywhere else there a Shortcut to the program.
  • On the TaskBar, when the program's minimized.
  • In the Title Bar of the application's toplevels,
  • Etc, etc.

So What Icons Does My Starpack Have, If I Don't Install Custom Icons?

Unless you install custom icons, your Starpack will get the icons (if any) that are present in the RUNTIME you wrapped into the Starpack. For example:

SDX wrap MYAPP.VFS -runtime TCLKIT.EXE

will give you a Starpack called MYAPP.EXE - which will have TCLKIT.EXE's icons.

So What Icons Do TclKit Runtimes Have?

Some of the commonly available Tclkit runtimes - and the icons they have are:

  • tclkit-8.5.8-win32.upx.exe/tclkitsh-8.5.8-win32.upx.exe: Twelve of the blue feather logo: 64x64,256 colours,32 bits-per-pixel,size 16936 -- 48x48,256 colours,32 bits-per-pixel,size 9640 -- 32x32,256 colours,32 bits-per-pixel,size 4264 -- 24x24,256 colours,32 bits-per-pixel,size 2440 -- 16x16,256 colours,32 bits-per-pixel,size 1128 -- 48x48,256 colours,24 bits-per-pixel,size 7336 -- 32x32,256 colours,24 bits-per-pixel,size 3240 -- 24x24,256 colours,24 bits-per-pixel,size 1864 -- 16x16,256 colours,24 bits-per-pixel,size 872 -- 48x48,256 colours,8 bits-per-pixel,size 3752 -- 32x32,256 colours,8 bits-per-pixel,size 2216 -- 24x24,256 colours,8 bits-per-pixel,size 1736
  • tclkit.exe/tclkit-win32.upx.exe: Six of the red Tk logo -- 32x32,16 colours -- 16x16,16 colours -- 32x32,256 colours -- 48x48,256 colours -- 48x48,16colours -- 16x16,256 colours.
  • bikit.exe - which has BLT and a few other packages in it: Four genie lanterns and three Tk logos - in various sizes and colours (seven icons total).
  • dqkit-win32-i386-all.exe - which has BLT and a few more other packages in it: Seven assorted DataQuest (the company that makes it,) logos.
  • tixtclkit.exe - which has Tix and a whole load of other packages built in: One big and one small Tix logo (a purplish, sun-flower looking thing), plus a black Tk logo (three icons total).

There's nothing wrong with the above icons, if you're making a Starpack for your own or in-house use. But if you're releasing an application commercially, then something relevant and distinctive is probably a good idea.

Most killer apps: WinZip (that G-clamp thing), wish (the feather thing), Tk (the Tk logo), Windows Media Player (the "lights, camera, action" board thing), Netscape (the lighthouse), Windows Notepad (the err... notepad), have their own unique icon to brand themselves with.

A Picture Is Worth A Thousand Words

If you want to see an app's icons - just viewing it in Windows Explorer (in "Large Icons", "Small Icons", and the other modes,) will show you some of them.

But downloading an icon viewer program like "Icon Sucker" (freeware) is more convenient. Click on an *.EXE or *.ICO file (or any other Windows file that contains icons) and "Icon Sucker" will display ALL the icons the file contains.

It's also a convenient method of checking that the EXE file you've added and deleted icons to/from, now has the correct icons in it.

So How Do I Get My Icons Into A Starpack?

Getting your own icons into a Starpack is a piece of cake. Once you've downloaded and installed the required software (listed below) - a five to ten line DOS batch file will have your custom icons installed into your Starpack in a few seconds (plus another minute or so for the UPX re-compression - if you're using it).

I'll walk through it step by step:


1. Get your icon file

There are just over three zillion icon library web sites on the Internet, so you can easily browse and pick something suitable. And a further squillion freeware/shareware/commercial icon editors. So if you prefer, you can design your own icons.

PAK With converters such as png2ico [L1 ] you can even use the Gimp program to draw the icons.

However you do it, I'll now assume that you've got your (one or more) icons - all loaded into an *.ICO file named MYICONS.ICO.


2. Download and install the following software (if you haven't got it already)

UPX
This is a EXE file compressor/de-compressor. All the above-mentioned runtimes are compressed with it. So if you want to use one of those, you'll need to de-compress it first because "Resource Hacker" can't handle UPX-compressed EXE files. (But if your runtime isn't UPX-compressed, you don't need UPX.)
Resource Hacker
Icons are stored in EXE files in a database type structure that can be edited. In other words you can ADD icons to - and DELETE them from - any EXE file. This is what "Resource Hacker" does (amongst other things).
GoRC
An "RC" to "RES" file compiler. You need this too. It's too complicated to explain here. See the "Resource Hacker" and "GoRC" documentation, if you want to know why. PAK The program windres in the mingw distribution does the same. Windres is GNU, so presumably it's also in Cygwin. The Microsoft original, which I think is called RC.EXE, is presumably available to people with Microsoft development systems. I chose GoRC because it's standalone, and has great documentation. This makes it easier for people who only want it for the icons. But if you've got something else, you may as well use that instead.
Icon Sucker (Optional)
See above,

The above programs are all freeware/open source - short downloads - and easy to install.


3. Copy the runtime exe you want to use

UPX decompresses in-place. In other words, the de-compressed output file OVERWRITES the compressed input file. So if you want to keep the compressed original, you must de-compress a COPY.

So - from the DOS command line - or your *.BAT file - and assuming BIKIT.EXE is your runtime:

COPY bikit.exe bikit1.exe

4. Decompress the runtime

Only required if the (copied) runtime is compressed (see above):

UPX -d bikit1.exe

5. Delete the icons you don't want

The following line will have "Resource Hacker" delete ALL the icons in your RUNTIME EXE:

"c:\Resource Hacker\ResHacker.exe" -delete bikit1.exe , bikit2.exe , icongroup,,

The two commas after "icongroup" matter. See the "Resource Hacker" documentation if you want to know why. Or how to modify the above so as to keep some icons.

You may also want to delete the versioninfo if you don't want your package identified as coming from DataQuest (dqkit) or Equi4 Software (tclkit), in which case do the following instead:

"c:\Resource Hacker\ResHacker.exe" -delete bikit1.exe , bikit3.exe , versioninfo,,
"c:\Resource Hacker\ResHacker.exe" -delete bikit3.exe , bikit2.exe , icongroup,,

6. Create the RC file that describes the icons you want to add

An RC ("Resource Compiler") file is a text file that describes the "resources" (icons, cursors, dialog boxes, etc,) in the EXE file. The following one line file describes the icons (in MYICONS.ICO) that you want added to your EXE:

APPICONS ICON "myicons.ico"

If you've got more than one icon file, just add extra lines. E.g.:

ICONS1 ICON "these_icons.ico"
ICONS2 ICON "those_icons.ico"

If you deleted the versioninfo resource as above, you can include your own version information in the RC file and it will be added to the EXE along with the icons:

1 VERSIONINFO
FILEVERSION 0, 0, 0, 0
PRODUCTVERSION 0, 0, 0, 0
FILEOS 4
FILETYPE 1
{
    BLOCK "StringFileInfo" {
        BLOCK "040904b0" {
            VALUE "FileDescription", "..."
            VALUE "OriginalFilename", "..."
            VALUE "CompanyName", "..."
            VALUE "FileVersion", "..."
            VALUE "LegalCopyright", "..."
            VALUE "ProductName", "..."
            VALUE "ProductVersion", "..."
        }
    }
    BLOCK "VarFileInfo" {
        VALUE "Translation", 0x0409, 0x04B0
    }
}

See the GoRC documentation for the full details of the RC file syntax, or search for 'site:msdn.microsoft.com Resource Compiler'.

PAK: For dqkit and presumably tclkit, you should use TK instead of APPICONS so that the title bar icon automatically appears, otherwise you will have to set it manually with wm iconbitmap. Note that some versions of windows use serial order and others use alphabetical order when shell is searching for the first icon to display, so choose your names carefully.

Yeah, I tried using TK for that reason. But it didn't work. Didn't try very hard though. Gave it one go. Didn't work. Said "Stuff it. I'll stick with 'wm iconbitmap'".

J: If you use two lines, with both APPICONS and TK, then you get the icon in both Windows Explorer and the title bar. I used:

APPICONS ICON "myicons.ico"
TK ICON "myicons.ico"

7. Have GoRC ocnvert the RC file to a RES file

A RES file is the binary equivalent of the RC file. And since Resource Hacker expects its input in RES format, you've got to have GoRC convert your RC file to a RES file. Assuming your RC file is ICONS.RC, the following will have GoRC convert this to ICONS.RES:

"c:\GoRC\gorc.exe" /r icons

Consult the GoRC documentation if you need more details.


8. Add the new icons to the runtime exe

You instruct Resource Hacker to do this as follows:

"c:\Resource Hacker\ResHacker.exe" -add bikit2.exe , bikit3.exe , icons.res , ,,

9. Re-compress the runtime (if needed)

UPX bikit3.exe

10. Tidy up and exit

ERASE bikit1.exe
ERASE bikit2.exe
RENAME bikit3.exe bikit.exe

The above lines just get rid of the intermediate files and leave BIKIT.EXE as your new runtime with your custom icons in. DONE!


11. Tell Tcl/Tk about your icons

See below.


12. Wrap yor starpack

SDX wrap YOURAPP -runtime BIKIT.EXE

gives you the Starpack YOURAPP.EXE with your custom icons in it.

NOTE that you only need to paste the icons into the runtime ONCE. From then on you can edit your (Tcl/Tk) application, and re-wrap the Starpack whenever you want, without having to bother with the icons any more. They'll automatically be transferred from RUNTIME.EXE to STARPACK.EXE when you wrap the application.


Summary

Seems long and complicated. But once you've downloaded and installed the required software, the following DOS *.BAT file will have the icons in MYICONS.ICO installed into RUNTIME.EXE in just a few seconds (plus another minute or so for the UPX re-compression, if you're using it):

@REM Tell DOS to shut up...
@ECHO OFF

SET  TCLKIT="D:\Tcl\bin\tclkit-gui-8510.exe"
SET UPX_BIN="D:\Programme\upx307w\upx.exe"
SET    GORC="D:\Programme\GoRC\gorc.exe"
SET RESHACK="D:\Programme\ResHack\ResHacker.exe"

REM Copy the original runtime (so UPX doesn't overwrite it)...
COPY %TCLKIT% %CD%\RUNTIME1.EXE

REM De-compress the EXE (if needed)...
%UPX_BIN% -d runtime1.exe

REM Delete ALL the existing icons from it (see above if you want to keep some)...
%RESHACK% -delete runtime1.exe , runtime2.exe , icongroup,,

REM Create the RC file describing the icons you want to add
REM (Here, we do this on the fly - using the DOS ECHO command)...
ECHO APPICONS ICON "myicons.ico" >  icons.rc
ECHO TK       ICON "myicons.ico" >> icons.rc

REM Have GoRC convert ICONS.RC to ICONS.RES...
%GORC% /r icons.rc

REM Have Resource Hacker add the icons to the runtime...
%RESHACK% -add runtime2.exe , runtime3.exe , ResInfo.res , ,,

REM Re-compress the runtime (if required)...
%UPX_BIN% runtime3.exe

REM Tidy up and finish...
ERASE runtime1.exe
ERASE runtime2.exe
ERASE icons.rc
ERASE icons.res
RENAME runtime3.exe runtime.exe

REM Leave the window open. Just in case you want to read the output.
PAUSE

Obviously, you'll have to edit the above BAT file to your system and requirements.

NOTE! I haven't run/tested the typed in copy (it's the script I use, but typed in from memory). So check the syntax carefully. And use it at your own risk.

In particular, NEVER EVER use wildcards - "*" and "?" - with the ERASE command. Early versions of DOS treat "ICONS*.*" the same as "*.*". You don't want to find out the hard way that your DOS is one of those.


Getting Tcl/Tk to use the right icons

(to be cont'd)


AF: Sorry to bust in on your howto here (feel free to remove my comment) but I wanted to point out that you can do this with icons.tcl windows icons (which will soon be integrated into sdx) as well

My understanding was that windows icons could only REPLACE an existing set of icons. My solution allows you to DELETE (or KEEP) existing icons - and ADD new ones. You end up with the (zero or more) icons you require.

AF: Yes that is partially true. you can replace individual icons thereby branding your app but you may not add additional ones. you may replace a single icon and keep the others. I have not run into a need to add additional icons to an executable, those types of icons may be included in the vfs.

I see what you're saying. But I can't see how you can keep any existing unwanted icons in your EXE file. Although the Tcl programmer can ignore these, Windows won't. When Windows shows an EXE file's icon and filename - as it does in places like Windows Explorer, in Shortcuts, and on the Start Menu - it first figures out how much space it has to display the icon (width x height x number_of_colours) - and then goes looking in the EXE file for the best match - sizing the EXE file icons up or down - or using its own defaults - as it sees fit.

So if you leave other icons in the EXE file, Windows may grab one of these. And while it might pick a 16x16x256colour icon on Joe Blogg's 800x600x256 colour PC, it may go for the 48x48x16 colour one on John Doe's 3000x2000 true colour beast. If those icons have different designs (one of your choosing, and a leftover from somebody else,) you're going to get inconsistent results. The only way to make sure that Windows always picks only your apps icons is to delete everything else - and give it no other choice.

jcw: ... leading to icons which don't always look good. The other option is to convert whatever icon you have to 6 variants (looks best when starting from a high-resolution one), tweak a few if needed, and then put them all in the executable. The extra resolutions were added in an attempt to serve everyone.

Yes jcw. I assume that the single icon design you want Windows to (always) use is pasted into the EXE in the commonly required variants. As you do with tclkit.ico. I.e.:

  • 16x16 - 16 colours
  • 32x32 - 16 colours
  • 48x48 - 16 colours
  • 16x16 - 256 colours
  • 32x32 - 256 colours
  • 48x48 - 256 colours

PS: Is the reason I can't get your method to work even with tclkit-win32.upx.exe, that the six icons you specify must ALSO be in exactly the SAME ORDER as in your tclkit.ico? Ie:-

  • 16x16, 4-bit (16-color)
  • 16x16, 8-bit (256-color)
  • 32x32, 4-bit (16-color)
  • 32x32, 8-bit (256-color)
  • 48x48, 4-bit (16-color)
  • 48x48, 8-bit (256-color)

The icon file I was trying to paste in has those six icons, but they're in a different order. And looking at the code in SDX's wrap.tcl, I wondered.

jcw: No, order should not matter. SDX replaces them individually. See [L2 ].


male 2004-02-17: What a mess! Sorry, but you can't be true, suggesting to make such a big noise to customize the icon of a starpack!

What's simply about this?

set iconFile [file join [file dirname [info script]] bitmap idtagviewer.ico];
wm iconbitmap . $iconFile;

Just deal with an icon bitmap file inside the virtual filesystem of the starpack and "assign" it to be used by the window manager!

That's all!

MNO 2004-02-17: I think you've missed one of the points of the above discussion - the original author(s) want to influence not only the run-time displayed wm icons as your code does but also the icons that Windows displays next to the filename in file manager (explorer) windows. Your runtime code above cannot address this! See where it says "In Windows Explorer, by the program's filespec." above.

male - 2004-02-17: Ok, I revoke and claim the opposite! ;-)


LV: where does one find txltclkit - google doesn't seem to find it...

Peter Newman 2005-03-13: I assume that the txltclkit above was a typo; it should be TixTclKit. Google reports a copy here (though whether or not that's the one I was referring to above, I can't remember).


I tried your way and I couldn't seem to get it to work. I went back and did JCW's way and it worked like a charm. Much easier, too.


RLH 2005-08-03: Reading this I would have to conclude that there needs to be a better and easier way of doing it!

EKB 2006-03-02: There is, aside from using UPX for compressed files, but it costs a (little) bit of money. I use Heaventools' Resource Tuner . It has a nice GUI and is very easy to use. I won't stop using it, but am planning to add a completely scripted, command-line version so I can put it into my build process.

RLH 2006-03-02: Wouldn't it be better if the process itself was modified? When I pack something with PAR (it's a Perl thing), I can specify -ico on the command line (or some command like that) and it replaces the application icon with the one I feed it. Starpack should allow the same thing.

jcw: I'm always for progress. The logic for starpacks is unfortunately very tricky:

  • there's an icon in the tclkit exe
  • the exact same icon must be in VFS, and be called "tclkit.ico"
  • the new icon must have all resolutions which need to be replaced

What the current sdx wrap mechanism does is search for the current icons in the exe (one at a time, order does not matter), using the tclkit.ico file from VFS, and then replaces each one by overwriting bytes. There is no decoding of the exe - this works entirely by string searching. So the tclkit.ico is crucial, and it has to match what's in the exe to be able to locate each icon.

Improvements are always welcome, both to the techniques used and to the way this is exposed for actual use. It's all done in pure Tcl.


WJG 2006-05-27: In looking for an easy solution to getting the icons running I stumbled across a nifty app called ICONFX . It was nice-n-easy. Load a 48x48 8-bit png file, pick the pull-down menu item for make icon, pick yer images, save it as tclkit.ico and go! Worked first time. 10/10!

RLH I am getting the following error when following your instructions:

"Creating the EXE file"
customizing tclkit.ico in executable
icon 32x32/16: replaced
icon 16x16/16: replaced
icon 32x32/256: NOT SAME SIZE
icon 48x48/256: NOT SAME SIZE
icon 48x48/16: replaced
icon 16x16/256: NOT SAME SIZE

I am choosing a 48x48 8-bit png file...any suggestions would be helpful as this would be way cool for my stuff on Windows. I will try again tomorrow, just in case it as "user" error. : )

RLH: The continuing saga! I got the icon to replace but now I get an error message when I try to start the exe file:

This application has failed to start because the application configuration is incorrect. Reinstalling the application may help fix the problem.

RLH: I refreshed tclkit and sdx and now it works. Cool!

MHo 2008-05-28: Hm... I used to replace the tclkit.ico in the above way, and it worked until some time I cannot exactly remember. I use the newest sdx and the latest tclkit (8.4.17) under windows. I currently get the following error:

Projekt: dduclient2
 customizing tclkit.ico in executable
  icon 32x32/16: replaced
  icon 16x16/16: replaced
  icon 32x32/256: replaced
  icon 48x48/256: NOT FOUND
  icon 48x48/16: NOT FOUND
  icon 16x16/256: replaced
5 updates applied

I havent't changed the procedure for creating the icon set in any way. What's going on?

AF: It sounds like your new tclkit has 48px icons where the old one did not, and your ico does not either. just add some 48px versions to your tclkit.ico.

MHo: The .ico contains, as ever, 16-, 32 and 48px-Icons... This error even occurs if you qwrap some project, then unwrap and use the default tclkit.ico from there. So I guess the reason is not the .ico but some change in the tclkit.exe? Has anyone a tip how to set the 48pt icons without res-hacking???


RLH 2006-06-08: Is there a way to use the alpha blended ico that XP uses? I can use the above and it works but the icon is not "optimal" on XP with the fischer-price theme going.


VM 2006-12-04: I tried the above methods to add custom icons with the tclkitsh runtime and none of the above methods worked.


EF: I have used the ideas above and automated the whole thing in my make library , also known as Another Make Replacement. The library will do all the decompression/recompression, resource hacking and the such for you, given you can access the binaries (which are made part of the download package to make sure you can).


Laif: Thank you SO much for this very thorough tutorial. It's really cool to find someone who comes along and wants to describe the entire process like this, in detail. I think you're right, that this is a much more thorough method than simply using the current tcl ico library. A couple years ago, I found some tutorials on the net which helped me learn to navigate the master boot record, and install the xosl boot loader, along with several other OSs. It was invaluable to learn this stuff... Dan Goodell's way of describing things, reminds me of yours. You are very thorough, and a person can actually get something cool accomplished, by following through step by step... and then, of course that gives you a springboard - you start learning the terminology, and concepts - so that you can delve more deeply into the subject, later. Just wanted to voice my appreciation for what you've done here. :-)


Ikatz: Hi, I am new in this world of TCL/TK and currently I am working on a GUI that uses BLT and TIX (Windows XP). I want to compile them into one executable file, but I haven't understood if using the tutorial explained above I would be able to do it. I have downloaded tixtclkit.exe and Tclkit.exe. First I tried with a file.tcl that only uses Tix and it worked just using Tixtclkit.exe, but if I use another file that uses both BLT and Tix it doesn´t seem to find the BLT library (with the Tixtclkit). So I wanted to know if there´s a way of creating an executable file in this case.

Thanks in advance for your help and thanks too for this Wiki, it is helping me a lot :)

problem with 48-bit icons and scx

MHo 2008-07-04: Still using the latest 8.4 tclkit, which seems to be 8.4.17 from [L3 ]. And I still have the icon problem (48bit icons are not found and replaced by SDX), which was discussed here [L4 ] and there [L5 ] - I couldn't get it to work. I don't want to switch to 8.5 for this reason... anybody out there with a solution?

APN: The only method I've found that consistently works across all starpack versions is that in Custom Icons For Win32 Starpacks - The Real Story. I've a makefile that does all the steps. The other solutions seem simpler but I spent so much time struggling every time I changed the base kits to get things working again. Perhaps it was pilot error, I don't know. But after switching to the Custom Icons For Win32 Starpacks - The Real Story method, I've had no problems. MHo Thanks. For now, I found a tclkit 8.4.19 at http://www.patthoyts.tk/tclkit.html - this behaves as expected.

What works with tclkit858+ ?

HaO: Since TCL 8.5.8, the window icon for the starpacks on page , by Pat Thoyts, changed to tclsh.ico (the feather from the tcl core distribution). This file includes a 64x64 bit resolution icon and thus, the upper JCW-Method 1 does not work any more.

In contrast, the starpack for tcl8.5.8 of René Zaumseil (WindowsNT_kbsvq8.5-gui.exe ) still uses the old icon and thus works with method 1.

According to New windows icons in tclkit858.exe fail replacement ,2009-11-28 , by PT, there are two additional steps to method 2:

Split the starpack before unpacking using upx, yielding a starpack.head and starpack.tail:

sdx mksplit starpack.exe

decompress the exe section:

upx -d starpack.head

replace the icon resource

repack:

upx --best --compress-resources=0 starpack.head
copy /b starpack.head + starpack.tail starpack.exe

Do not use a 256x256 icon, because most icon compilers do not support it.

In Slimming down a tclkit, 2010-01-20 , PT proposes to rename the head part to an extension .exe and use highest packing level:

upx -q --ultra-brute --compress-resources=0 mytclkit.head.exe 

I changed successfully from method 1 to method 2 using Pat Thoyts starpacks. Experience:

  • Base starpack: tclkit858.exe
  • Resource compiler from VC9 (Microsoft Visual C++ 2008 Express Edition)
  • No sdx mksplit used.
  • Replaced only the icon, not the strings.
  • Icon file: same structure as tclsh.ico but a 256x256 resorce added (IMHO important).
  • RC file only contains TK icon group ( TK ICON "myicons.ico" ). This works for me and adding a copy in APPICONS icons group doubles the required file space.
  • Icon editor: IcoFX
  • Template for tclkit.inf file to customize the resource strings:
FileDescription "Des"
FileVersion 3.0
LegalCopyright "copyright"
ProductName "Aplliname"
OriginalFilename "myexe"
CompanyName "my company"
ProductName "prod name"
ProductVersion "3.0"
Comments "Comments"

2011-09-29: I made tests with this method and tclapp from tcldevkit with basekits from ActiveTcl 8.5.10.1. If one of the following conditions are true:

  • When Reshacking the Icon of the Basekit (base-tk-...exe) before wrapping (with TclApp):
  • When compressing the starpack exe with upx before or after wrapping:

then, dll loading does not work any more. In consequence, scripts can not be compiled, because the tbload.dll can not be loaded any more.

Decompress / Compress

John: I didn't have much luck with replacing the resources within the compressed executable but I was able to decompress, swap icons and recompress without issues.

Tools:

Steps:

  1. Use any graphics program to create a PNG file (I used Inkscape )
  2. Use IconFX to convert the PNG file to an ICO file (I used the default Windows icon set that went to 256x256x32)
  3. 'upx.exe -d <filename.exe>' to decompress into normal executable
  4. Use IconFX's Tools->Resource Editor to open the EXE file and "change" the icon to the new ones
  5. 'upx.exe --best --compress-resources=0 <filename.exe>' to recompress (Thanks HaO )

Thanks everyone!


wdb: On my Linux-based PC I did the same, using windows-based executables run by Wine. Conversion from any img format to *.ico can be done by convert , an ImageMagick tool as well as with Gimp.


RS 2010-07-12: I was asked to change the icon, description strings etc. for a Starpack I make. Reading this page, and surfing around, I found it was sufficiently simple to

 1. cp tclkit.exe mykit.exe
 2. upx -d mykit.exe
 3. start Resource Hacker with GUI, drag mykit.exe into it
 4. exchange icons from .ico file
 5. edit Version Info, recompile, save
 6. upx mykit.exe

Ashoks proposal on clt on 2011-07-25

HaO Ashok posted on Custom icon in starpack ,2011-07-24 about this issue:

Try the following :

Download ctcl.exe from sourceforge in the WiTS repository:

This is nothing but a tclkit with twapi bound in and has commands to write version and icon resources.

split the starpack using sdx. This is required to separate the "real" exe from the kit data. This step is vital if the size of the resource(s) being written might be larger than the original resources.

ctcl sdx.kit mksplit mystarpack.exe

This will create a mystarpack.head and .tail file

Write your version resource - something like

ctcl write_version_resource mystarpack.head -copyright "My copyright" -timestamp now -version 1.0.0 -productversion 1.0.0 ProductName "My Windows App" FileDescription "My starpack" CompanyName "Kevin Walzer" FileVersion "V1.0.0 Beta" ProductVersion "V1.0.0 Beta"

Write the icons from an external file. Note that TK is assumed to be the icon id used in the starpack. Sometimes it is APP. Adjust accordingly.

ctcl write_icon_resource mystarpack.head myicon.ico -name TK

Now put back the starpack data

copy /b mystarpack.head+mystarpack.tail mystarpack.exe

Done.

Advantags over other methods

  • works with any exe (not just starpacks) skipping the sdx mksplit step of course.
  • does not depend on the size/colors/depths of the icon resources
  • updates all version fields in the exe (I seem to remember some of the alternatives miss some)
  • arbitrary version resource strings can be updated

Caveat - only tested on two exes :-)

LAM 2021-10-06 : This work ok for me. I've used a 256px icon with win7/32.

See Also

SDX under Windows
Windows batch script for 'compiling' starpacks
Building Starkits and Starpacks using a Makefile
icomaker - tcl only ppm to tclkit.ico converter