|
-
Apr 18th, 2001, 06:50 PM
#1
Thread Starter
Frenzied Member
The following code is giving me some problems when getting AOLs version info.. its 4.4.2286, but all the program shows is 0.00... as for testing other programs, it will only return file versions in 2 or 3 numbers - it will never give the whole version (like 2.2.6B).. does anyone know how to change this, so it will return only the version, with no formatting of the version??
Code:
Private Declare Function GetFileVersionInfo _
_
Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal _
_
lptstrFilename As String, ByVal dwHandle As _
Long, ByVal _
dwLen As Long, lpData As Any) As _
Long
Private Declare Function GetFileVersionInfoSize _
_
Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal _
_
lptstrFilename As String, lpdwHandle As Long) _
As Long
Private Declare Function VerQueryValue _
Lib "Version.dll" _
Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock _
_
As String, lplpBuffer As Any, puLen As _
Long) As Long
Private Declare Sub MoveMemory Lib _
"kernel32" _
Alias "RtlMoveMemory" (dest As Any, ByVal Source As _
_
Long, ByVal Length As Long)
Private Type VS_FIXEDFILEINFO
dwSignature As Long
dwStrucVersionl As Integer ' e.g. = &h0000 = 0
dwStrucVersionh As Integer ' e.g. = &h0042 = .42
dwFileVersionMSl As Integer ' e.g. = &h0003 = 3
dwFileVersionMSh As Integer ' e.g. = &h0075 = .75
dwFileVersionLSl As Integer ' e.g. = &h0000 = 0
dwFileVersionLSh As Integer ' e.g. = &h0031 = .31
dwProductVersionMSl As Integer ' e.g. = &h0003 = 3
dwProductVersionMSh As Integer ' e.g. = &h0010 = .1
dwProductVersionLSl As Integer ' e.g. = &h0000 = 0
dwProductVersionLSh As Integer ' e.g. = &h0031 = .31
dwFileFlagsMask As Long ' = &h3F for version "0.42"
dwFileFlags As Long ' e.g. VFF_DEBUG or VFF_PRERELEASE
dwFileOS As Long ' e.g. VOS_DOS_WINDOWS16
dwFileType As Long ' e.g. VFT_DRIVER
dwFileSubtype As Long ' e.g. VFT2_DRV_KEYBOARD
dwFileDateMS As Long ' e.g. 0
dwFileDateLS As Long ' e.g. 0
End Type
Private Function CheckFileVersion(FilenameAndPath As _
Variant) As Variant
On Error GoTo HandelCheckFileVersionError
Dim lDummy As Long, lsize As _
Long, rc As Long
Dim lVerbufferLen As Long, lVerPointer As _
Long
Dim sBuffer() As Byte
Dim udtVerBuffer As VS_FIXEDFILEINFO
Dim ProdVer As String
lsize = GetFileVersionInfoSize(FilenameAndPath, lDummy)
If lsize < 1 Then Exit Function
ReDim sBuffer(lsize)
rc = GetFileVersionInfo(FilenameAndPath, 0&, lsize, sBuffer(0))
rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
'**** Determine Product Version number *
' ***
ProdVer = Format$(udtVerBuffer.dwProductVersionMSh) & "." & Format$(udtVerBuffer.dwProductVersionMSl)
'Full number:
'ProdVer = Format$(udtVerBuffer.dwProductVersionMSh) & "." & Format$(udtVerBuffer.dwProductVersionMSl) " & _
"& "." & Format$(udtVerBuffer.dwFileVersionLSh) & Format$(udtVerBuffer.dwFileVersionLSl)
CheckFileVersion = ProdVer
Exit Function
HandelCheckFileVersionError:
CheckFileVersion = "N/A"
Exit Function
End Function
Private Sub Command1_Click()
MsgBox CheckFileVersion("C:\Program Files\aim95\aim.exe")
End Sub
-
Apr 19th, 2001, 04:51 AM
#2
See the line that starts with "ProdVer =", then there's a comment that says "Full Number:"? I think the commented line after it is supposed to show the full number, but it doesn't show the version the same way as the properties window for the exe does.
Just put this line in place of the first "ProdVer =" line:
Code:
ProdVer = Format$(udtVerBuffer.dwProductVersionMSh) & "." & Format$(udtVerBuffer.dwProductVersionMSl) & "." & Format$(udtVerBuffer.dwFileVersionLSh) & "." & Format$(udtVerBuffer.dwFileVersionLSl)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|