6

The LA Fox Developer Newsletter
August 1999
Use Version Information to
Keep Track of Executables
A user is phoning you for help. Are you sure you are talking
about the sameversion?

If you have more than one build of your application in the field,
you need a way of knowing which one a given person is using.
Visual FoxPro (5.0 and above) can help with this, by branding
the executable with a version number and related information.

To see how this works, open the application in Project Manager,
then click on Build, then Versions. You will see a dialog in
which you can enter a version number, product name, company
name, file description, and several similar items (see Figure 1).
The version number consists of three parts: major, minor and
revision.


Figure 1: Use this dialog to specify version information.

When you build the application, this information gets stored
inside the EXE file. From there, it can be accessed both
programmatically and by the user.

More interestingly, if you check the Auto Increment option within
the dialog, the version number will be incremented with each
build, thus ensuring that it is unique within your application. (In
fact, it is the revision number which is incremented; if you want
to change the major or minor component, you must do so
manually.)

Over to the user

So how do you find out which version a given user is using? One
option would be to ask them to look at the file properties of the
application’s EXE file. To do that, they must locate the file in
Windows Explorer or a folder window, right-click on it, select
Properties, then click on the Version tab. All the information that
you entered in the Project Manager’s Versions dialog will be
displayed (see Figure 2).
Figure 2: The version information can be accessed from the
Windows shell.

A slicker approach would be for the application itself to retrieve
this information, and to display it somewhere where the user
can easily get at it - such as in the About box on the Help
menu.

To retrieve the version information from within your program, call
the AGETFILEVERSIONO function. Pass it two parameters: the
name of an array to hold the information, and the name of the
executable file. As with most of the “A” functions, if the array
does not already exist, the function will create it. If it does exist,
it will be re-sized as necessaly . . .

For example, this command retrieves version information from a
file called MYAPP.EXE, and stores it in array aVer:

InReply AGETFILEVERSION(aVer,”MYAPP.EXE”)

By the way, the function returns zero if the file does not contain
Windows versioning information.

The three-part version number can be found in the fourth ele-
ment of the array (check the VFP help for the contents of the
other elements). It is returned in decimal format, with periods
between the components. So if you entered 1, 2 and 3 in the
major, minor and revision fields respectively, the number would
be returned as 1.2.3. Note that the three components are
strictly numeric: you cannot specify 1 .2a, nor could you make a
distinction between 1.2 and 1.02.

GETFILEVERSION() was introduced as a native command in
VFP 6.0. In earlier releases, the equivalent functionality was
provided within Foxtools.

Copyright Mike Lewis Consultants Ltd. 1999.
Page 6

6