Using the CVersion class
When you click on a version resource in the Resources list box of WinWatch, the name of the current module (sModCur, saved from when the module changed) is passed to the GetVersionData function. Notice that the module handle isn’t involved. GetVersionData simply creates a CVersion object and reads its properties, formatting them into a given maximum width. Here’s the first part of the code:
Function GetVersionData(sExe As String, _
Optional ByVal cMaxChar As Long = 40) As String
Dim version As New CVersion, s As String
On Error GoTo NoVersionData
With version
‘ Initialize version object
version = sExe
‘ Read and return properties
s = s & WordWrap(.ProductName, cMaxChar) & sCrLf
s = s & “Exe type: “ & .ExeType & sCrLf
s = s & “Internal name: “ & .InternalName & sCrLf
§
WinWatch works great for displaying the version data of running executables, but you might prefer to find version data by filename. If so, use the Version tab of the All About program. Clicking the New button brings up an Open dialog box in which you can select a program, a DLL, a control, a font file, or another executable file. You can learn a lot about resources by experimenting on various programs and DLLs, including compiled Visual Basic programs. Compare programs created with versions 3 and 4 of Visual Basic. Compare system DLLs to programs, or compare programs created with other languages to Visual
Basic programs.
Normally, version data comes from a resource script (an RC file). Version data has a special format similar to (but more complicated than) the resource formats described in the sidebar “Anatomy of a Resource Block,” page 440. It’s possible to enter version data in a resource script and compile it into your Visual Basic program as described in Chapter 7, but Visual Basic provides an easier way: you can use the Make tab of the Project Properties dialog box, accessed by clicking the Options button in the Make Project dialog box. Figure 8-6 shows the Project Properties dialog box entries for the All About program. Figure 8-7 (on the following page) shows how these entries are displayed in the All About program.
Figure 8-6. The Project Properties dialog box.
Figure 8-7. The version resources of the All About program.