I recently got a request from a FlashKit user for help with a problem in the latest version of Zinc. I'm the moderator of the Standalone and Applications forum there, so this kind of request isn't anything out of the ordinary for me. Normally such a request would be my cue to give SWF Studio a little plug, but this problem was so simple that I thought the guy was just doing something wrong. I had a closer look and discovered that it was definitely a bug and that it was first reported over a year ago.

The problem is that you can't set the version number of your EXE files with Zinc. If you use any kind of installation software you already know why this is a problem. It's not a show stopper, but it's definitely annoying.

Normally there isn't much that we at Northcode can do for MDM Zinc users, except offer a superior swf2exe tool alternative. However, I decided to create a little utility that will allow you to correctly set the version information in your Zinc EXE files and I'm making it available for FREE.

Version Information Basics

Installation tools like Inno Setup, Nullsoft, MSI, Install Shield (and many others) can use the version information resource in an EXE file to determine whether the file you're about to install is newer or older than one that may already be installed. Why do this? To avoid reinstalling the same version of an EXE file, or worse, installing an old EXE over a newer one.

A version information resource starts with some fixed sized fields like the File Version, and the Product Version, followed by an optional variable sized structure (StringFileInfo) that contains the File Version and Product Version again, but in string format this time.

The Windows GetFileVersionInfo API function, that installation tools use, retrieves the File Version from the fixed sized structure at the beginning of the version information resource.

Here's the version information resource extracted from a SWF Studio application that shows all of the version numbers.



The Problem

Zinc doesn't set the File Version or the Product Version in the fixed size structure and it doesn't set the File Version in the variable sized structure. In fact the File Version and the Product Version in the fixed size header seem to be hard coded and don't even match in a freshly built Zinc application, they are set to 3.0.0.0 and 1.0.0.1 respectively.

Zinc does let you change the Product Version information in the StringFileInfo structure, but it doesn't let you set the File Version. I don't know of any tools that read or display the information from the StringFileInfo structure except for EXE file viewers.

The only way you can see this information in Windows is to right click on your file, select Properties and select the Version Tab. So to use your Zinc EXE files with an installer package, you have to pick one that allows you to use the Product Version from the StringFileInfo structure for file comparisons instead of the File Version. Good luck.

Here's the version information resource extracted from a Zinc application. You can see the problems with the mismatched version information. There's also something wrong with the other string resources not being properly terminated, but we'll leave that discussion for another time.



The Solution

I obviously don't have access to the Zinc source code so my only recourse was to find a way to fix the EXE file after it had been generated. It took me less than 30 minutes to build a simple command line tool to do exactly that. Writing this post took longer than fixing the problem!

usage: version.exe /path filespec /version #.#.#.#

Nothing with Zinc is ever easy, and modifying the version information is no exception. Zinc uses a compressed EXE file format to make your EXE files smaller. Unfortunately that prevents us from making simple changes like removing the bad version resource and replacing it with a proper one. This would not be an issue if they had thought to reserve some extra space in the version resource when it was created.

The version tool locates the existing version information in your EXE and modifies it in place. Since the default version number is set to 3.0.0.0, and there's no room to expand it, all your version numbers have to be exactly the same length. You can't have 3.0.0.10 because it would corrupt the version resource, so the version tool doesn't allow you to do that.

Actually that's not 100% accurate, we can set the version information in the fixed size area and leave the one in the StringFileInfo structure alone. It wouldn't be consistent, but it would give you a little more flexibility. If you supply the optional /dirty argument on the command line, the version tool will not attempt to modify the version information in the StringFileInfo structure and just modify the fixed size header fields.

After using the version tool on a Zinc EXE, the version infomation will be set correctly and will work happily with your installer tools. Since the version tool is a simple command line application you should be able to easily integrate it into your automated build process until MDM decides to fix this one for you.



No installer is required, the version tool is completely standalone and was designed to run on Windows XP and Windows Vista desktop operating systems.

Version: 1.0.0.0
Released: July 15, 2008
Download: version.exe (835KB)