What

Background

'What' is an implementation of the classic UNIX command, but this version can identify COM component locations and version numbers too.

Usage

what file|progid [sccsinfo]
The program is available for download from the download page.

Screen shot

In this example the version numbers and locations of 3 COM components were found.

Why

To test software installations it is very useful to know which versions of components are registered (if any), and in which location. This can identify installation and compatibility problems much faster than trawling through the file system to find files.

For multiple version checks the calls should be stored in a batch file for fast diagnosis.

Version numbers

In UNIX it is down to the programmer or build manager to decide the format of version numbers. A common format is major.minor

On Windows Microsoft have a standard version number format for version resources. There are Windows API functions to extract these version numbers from the executable's resource section. The standard Windows version number format is major.minor.special.build

Functions

1. Find the Windows version number and location of a COM component given the progid,
2. Find the Windows version number and location of a COM component registered in MTS given the progid. Components registered in Microsoft Transaction Server (MTS) and COM+ have slightly different registry entries and are handled by a special function in the program.
3. Find the Windows version number of a given executable name,
4. Find the SCCS identifiers of a given file (old compatibility mode).

Version history

7/1/2006 v0.4
1. Components built with Visual Studio .NET 2003 may have quoted file names in the registry. Previously this would cause GetFileVersionInfoSize to fail and not display the version number. The filename has leading and trailing quote characters removed before calling GetFileVersionInfoSize now.
2. The UNIX sccsid magic string is now stored differently in the program so only the genuine sccsid is displayed when called upon itself.

3/10/2002 v0.3
Windows version block added for testing the .exe, SCCS info carriage return and line feed display checks, test batch file added.

5/3/2001 v0.2
MTS checks added.

28/2/2001 v0.1
Windows version info checking added.

3/8/1999 v0.0
Classic version for DOS.

Hints and tips

1. To get progids for a COM component use a program such as OLEview to check the type library, or search the registry for the DLL name and get the progid from there,
2. Use batch files to check multiple component version numbers at the same time!

Implementation details

1. Displays output on the command line,
2. Searches for SCCSids and displays that as version information if sccsinfo is specified,
3. Displays version information for a Windows executable if the filename is found,
4. If a progid is specified it looks in the registry for the classid, finds the executable path name then gets its version info.
5. If the component is an MTS component it looks in HKLM\Software\Microsoft\Transaction Server\Components\{classid}, then finds the executable name by opening the DllServer registry key.

UNIX notes

On UNIX 'what' is intimate with the Source Code Control System (SCCS), it searches binary or text files for string identifiers inserted by SCCS to identify source file versions. This is useful because even in a binary executable we can see the source code versions that went into the build for the file.

The standard magic string identifier is @(#) followed by a null terminated string.

For UNIX programmers a quick way to get an SCCSid in your C code is to add:


static char *vcid=("@(#) "__FILE__" 1.1 "__DATE__" "__TIME__"\n");

This uses C preprocessor directives to insert the file name, date and time. The value 1.1 is shown as an example version number. It may be possible to get your makefile to automatically increment this number.

Windows notes

In Windows an executable has a VERSION resource to identify version number. Since Windows 95 DLLs, OCXs and EXEs which implement COM interfaces are registered in the operating system's registry by a program identifier (PROGID), which is a human readable string identifier, and a class identifier (CLSID) which is a machine generated 128 bit numeric identifier. The registry entry also stores the file location and this is how the operating systems knows where to load the component from.

Using this basic information we can find the version number of any registered component. This version of what automates this procedure - all you need to know is the progid.

Back to index.