Results 1 to 2 of 2

Thread: How do I get exe file version with old versions of the FSO?

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    How do I get exe file version with old versions of the FSO?

    Hi guys

    Bit of a problem I'm hoping you can help with. I've got an app that builds a report of all the exe files in a directory and and their version numbers. We're using it to pop up a message at client sites if they have an old version of one of our exe's. I've used the file system objects getFileVersion method to get the version info for the report but when we've come to use the client bit (the bit that checks the version they're using against the report) on a NT system it barfs because that method wasn't implemented until version 5.0.3715 of the scripting engine (which presumably came after NT).

    So my question is: is there a way UI can get the file version information on older Windows versions in the same format as that returned by getFileVersion (ie ##.##.##.##)?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How do I get exe file version with old versions of the FSO?

    Try something like
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type VS_FIXEDFILEINFO
    4.    dwSignature As Long
    5.    dwStrucVersionl As Integer
    6.    dwStrucVersionh As Integer
    7.    dwFileVersionMSl As Integer
    8.    dwFileVersionMSh As Integer
    9.    dwFileVersionLSl As Integer
    10.    dwFileVersionLSh As Integer
    11.    dwProductVersionMSl As Integer
    12.    dwProductVersionMSh As Integer
    13.    dwProductVersionLSl As Integer
    14.    dwProductVersionLSh As Integer
    15.    dwFileFlagsMask As Long
    16.    dwFileFlags As Long
    17.    dwFileOS As Long
    18.    dwFileType As Long
    19.    dwFileSubtype As Long
    20.    dwFileDateMS As Long
    21.    dwFileDateLS As Long
    22. End Type
    23.  
    24. Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" _
    25. (ByVal lptstrFilename As String, ByVal dwhandle As Long, ByVal dwlen As Long, lpData As Any) As Long
    26. Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" _
    27. (ByVal lptstrFilename As String, lpdwHandle As Long) As Long
    28. Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" _
    29. (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long
    30. Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, _
    31. ByVal Source As Long, ByVal length As Long)
    32.  
    33. Private sFileVer As String
    34.  
    35. Private Sub DisplayVerInfo(sFullFileName As String)
    36.    'modified slightly from the example in the API Viewer from [url]http://www.allapi.net/[/url]
    37.    Dim rc As Long
    38.    Dim lDummy As Long
    39.    Dim sBuffer() As Byte
    40.    Dim lBufferLen As Long
    41.    Dim lVerPointer As Long
    42.    Dim udtVerBuffer As VS_FIXEDFILEINFO
    43.    Dim lVerbufferLen As Long
    44.  
    45.    '*** Get size ****
    46.    lBufferLen = GetFileVersionInfoSize(sFullFileName, lDummy)
    47.    If lBufferLen < 1 Then
    48.       MsgBox "No Version Info available!"
    49.       Exit Sub
    50.    End If
    51.  
    52.     ReDim sBuffer(lBufferLen)
    53.    rc = GetFileVersionInfo(sFullFileName, 0&, lBufferLen, sBuffer(0))
    54.    rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
    55.    MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
    56.  
    57.    sFileVer = Format$(udtVerBuffer.dwFileVersionMSh) & "." & Format$(udtVerBuffer.dwFileVersionMSl) & "." & Format$(udtVerBuffer.dwFileVersionLSh) & "." & Format$(udtVerBuffer.dwFileVersionLSl)
    58. Label1.Caption = sFileVer
    59. End Sub
    60.  
    61. Private Sub Command1_Click()
    62. DisplayVerInfo "C:\My.Exe"
    63. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width