VersionInfo Component 1.1 - free
Last updated: 08/02/99, v1.1 MTS and EXE server support added
Initial Release: 07/11/99, v1.0
Download of the week 11/15/99
One of the most annoying problems with component-based programming (and ASP is just a good example for that) are
version conflicts or problems with specific builds of components (MDAC being an good example for this scenario).
On the right-hand side you can see the version information you can get for the ADO components using Windows NT Explorer.
Information obtained that is crucial is File Version - among others, which are not shown here.
So how can you get at this information using Active Server Pages? Without an additional component, there is no way.
|
|
Because of the problems we had with component versions, I created the Softwing.VersionInfo component that is capable of retrieving exactly
the same information as Explorer does - plus some additional, low-level, version information.
The additional bonus of this component (and I think this is the real killer feature) is that you don't need to know the DLL or EXE location and exact name - you can
also present it with a ProgId (like "ADODB.Connection" or "MSWC.BrowserCapabilities") and it will automatically locate the
corresponding DLL and extract the version information.
Methods
Bool GetByFileName(strFilename) |
Retrieves the version information for a specific file (can be any executable, DLL, OCX etc. that has
version information stored in its resources). You have to provide the full path, eg. c:\Myapp\Myapp.exe or
c:\winnt\system32\mycomp.dll. |
Bool GetByProgId(strProgId) |
If you want to query version information for COM components, then you can take the easy way of only
providing the ProgId (eg. ADODB.Connection) - the VersionInfo component then tracks down the corresponding DLL on its own (EXE
servers are currently not supported) and retrieves the version information. |
String GetValue(strKeyName) |
After executing one of the two above methods, you can query for specific version information (company name,
original file version, ...). See the samples provided with the component which keys you can query. |
Bool IsMtxObject() |
Check to see if the component in question is hosted in Transaction Server (such as "ExAir.History"). If this method returns true, then
no version information can be obtained (at least, not in this release of VersionInfo). |
The Bool type returns 1 for True and 0 for False. Excel handles Not statements correctly, however, ASP does not - you
have to compare to the numeric values.
Properties
All properties return long values.
FileFlags |
Returns specific file flags set for the component. See declares.vbs to find out what information
you can gather using this property. |
FileName |
Returns the full path of the DLL/EXE - this is especially useful when you have a ProgId and don't know where the DLL/EXE is stored on your harddisk. |
FileOS |
Returns the OS this component/application was written for. See declares.vbs to find out what information
you can gather using this property. |
FileType |
Information about the file type. See declares.vbs to find out what information
you can gather using this property. |
MajorVersion |
Returns the major version for the component/application. |
MinorVersion |
Returns the major version for the component/application. |
Samples
The component ships with an Excel workbook (vinfo.xls) that demonstrates many of the usage scenarios of the component and allows
you to test the component's functionality interactively.
Also, there is a full-featured ASP example (in the downloadable ZIP)- and you can take the code
and port it to any other Automation-capable environment if you like.
Retrieving Version Information
This example (Excel sub) retrieves common version keys for the ADO library (opened via the ProgId).
Sub GetADOVersion()
Dim xObj As Object, bResult As Boolean
Set xObj = CreateObject("Softwing.VersionInfo")
bResult = xObj.GetByProgId("ADODB.Connection")
If Not bResult Then
MsgBox "Could not locate the ADO files."
Exit Sub
End If
Dim strValue As String, aKeys As Variant, i As Integer
aKeys = Array("CompanyName", "FileDescription", "FileVersion", _
"InternalName", "LegalCopyright", "OriginalFilename", _
"ProductName", "ProductVersion")
For i = 0 To UBound(aKeys)
strValue = strValue & aKeys(i) & ": " & xObj.GetValue(aKeys(i)) _
& vbCrLf
Next
MsgBox strValue
Set xObj = Nothing
End Sub
To the right you can see the results you get with ADO 2.1. Note that all version information you can
retrieve via the Explorer Properties dialog box is available to you via GetValue(..).
If you want to obtain more information, then please see the next example about version flags.
|
|
Retrieving Version Flags
This example (Excel sub) retrieves additional version flags for the ADO library (opened via the ProgId).
Sub FlagsByProgId()
Dim xObj As Object, bResult As Boolean, strResult As String
Set xObj = CreateObject("Softwing.VersionInfo")
bResult = xObj.GetByProgId("ADODB.Connection")
If Not bResult Then
MsgBox "Could not load ADO files."
Exit Sub
End If
strResult = "Major Version: " & xObj.MajorVersion & vbCrLf
strResult = strResult & "Minor Version: " & xObj.MinorVersion & vbCrLf
strResult = strResult & "File Flags: " & xObj.FileFlags & vbCrLf
strResult = strResult & "File OS: " & xObj.FileOS & vbCrLf
strResult = strResult & "File Type: " & xObj.FileType & vbCrLf
MsgBox strResult
Set xObj = Nothing
End Sub
Installation and Download
Before using the component you have to register it using the regsvr32 utility:
regsvr32 vinfo.dll.
Download (size is approx. 26KB)
The most current version number of the component is 1.1. It is compiled with Visual C++ 6.0 SP3 using ATL.
If you do have any questions, please feel free to send mail to Christoph Wille.
|