Testing version numbers
You can use the Windows API version functions to display version information of EXEs (as WinWatch and All About do), but more likely you’ll want to read the version numbers of DLLs (or controls) used by your program. Then, if the DLL version is incompatible with your program, you can terminate with a polite request to update the DLL rather than with a rude command to boot the system.
For example, imagine you had a DLL written in C++ named VBUTIL32.DLL (similar to the one provided with the first edition of this book). Let’s say you wanted to make sure you hadn’t accidentally overwritten the Visual Basic Utilities DLL with the Vermont Business University Tools for Industrial Liquidity DLL:
Sub ValidateVBUtil()
Dim verUtil As New CVersion, f As Boolean
Const sUtil = “C Utility Functions for Visual Basic”
verUtil = “VBUTIL32.DLL”
If verUtil.FileVersionString <> “1.00” Or _
verUtil.Company <> “MS-PRESS” Or _
verUtil.Description <> sUtil Then
MsgBox “Invalid DLL”
End
End If
End Sub
Why not use this technique on VBCore? Because VBCore is a COM component, and components have a more sophisticated and flexible version system. Normally, you use version validation only on DLLs that aren’t COM components.
What’s in a Name?
How do you name a program? Let me count the ways:
-
You can assign a name as the caption of your main form. The main form name in WinWatch is WinWatch, and you can see from its display that its class name is ThunderForm. You can expand it to see
all the separate windows for its controls. Its owner is the window
described in the next item.
-
You can assign a name to the Title property of the App object by assigning a string to the property at run time. You can assign App.Title at design time by filling in the Title field of the Make tab of the Project Properties dialog box. In WinWatch, the title is Windows Watcher. The WinWatch display shows this as a separate window with class ThunderMain. You can’t see this window on the screen. Perhaps it’s hiding behind the main form. The App.Title name, not the caption of the main form, appears in the Top Windows list box (and in the Windows task list).
-
You can enter a Product Name value in the Type field of the Project Properties dialog box. In WinWatch, this name is WindowsWatcher (no space in order to distinguish it from the Title). This name is embedded in the EXE file as a version resource. You can see it when you view VERSION resources for WINWATCH.EXE. This name is also the App.ProductName property.
-
You can enter a name in the Project Name field on the General tab of the Project Properties dialog box. For WinWatch, this name is the last unique name I could think of: WinWatcher. The Project Name is used in the Visual Basic title bar and in the Object Browser. It will be used as the OLE server name if you make your project a server.
-
And, of course, you have the project filename (WINWATCH.VBP) and the program filename (WINWATCH.EXE).