Hi everybody

I guess that this is the right forum , to ask about this :

I want to get version for a file so I use this :

VB Code:
  1. Private Type VS_FIXEDFILEINFO
  2.    dwSignature As Long
  3.    dwStrucVersionl As Integer
  4.    dwStrucVersionh As Integer
  5.    dwFileVersionMSl As Integer
  6.    dwFileVersionMSh As Integer
  7.    dwFileVersionLSl As Integer
  8.    dwFileVersionLSh As Integer
  9.    dwProductVersionMSl As Integer
  10.    dwProductVersionMSh As Integer
  11.    dwProductVersionLSl As Integer
  12.    dwProductVersionLSh As Integer
  13.    dwFileFlagsMask As Long
  14.    dwFileFlags As Long
  15.    dwFileOS As Long
  16.    dwFileType As Long
  17.    dwFileSubtype As Long
  18.    dwFileDateMS As Long
  19.    dwFileDateLS As Long
  20. End Type
  21.  
  22.  
  23. 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
  24. Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long
  25. Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long
  26. Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal Source As Long, ByVal length As Long)
  27.  
  28.  
  29. Public Function GetFileVersion(FilePath As String) As String
  30. Dim Rc As Long, lDummy As Long, sBuffer() As Byte
  31. Dim lBufferLen As Long, lVerPointer As Long, udtVerBuffer As VS_FIXEDFILEINFO
  32. Dim lVerbufferLen As Long
  33.  
  34. lBufferLen = GetFileVersionInfoSize(FilePath, lDummy)
  35.  
  36. If lBufferLen < 1 Then
  37.     GetFileVersion = "0"
  38.    'GetFileVersion = "No Version Info available"
  39.    'Err.Raise 1000, , "No Version Info available"
  40.    Exit Function
  41. End If
  42.  
  43. ReDim sBuffer(lBufferLen)
  44. Rc = GetFileVersionInfo(FilePath, 0&, lBufferLen, sBuffer(0))
  45. Rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
  46. MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
  47.  
  48.  
  49. GetFileVersion = Format$(udtVerBuffer.dwFileVersionMSh) & "." & Format$(udtVerBuffer.dwFileVersionMSl) & "." & Format$(udtVerBuffer.dwFileVersionLSh) & "." & Format$(udtVerBuffer.dwFileVersionLSl)
  50.  
  51. End Function

Windows properties show this :


Using the APIs method I get this (2.0.-14809.42)

The question is what my method needs to get that number surrounded by the first red elliptical mark (in the image).

Thanks