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: