Hi,
How to get the file version from a folderitem (.exe)?
(on Windows desktop, non web)
Hi,
How to get the file version from a folderitem (.exe)?
(on Windows desktop, non web)
Not sure who I got this from.
Function GetVersion(f as folderitem) As string
dim version as string
dim totalSize, toss as Integer
dim info as MemoryBlock
dim passIn, fixedInfo as MemoryBlock
dim buffLen as Integer
dim highBits, lowBits as Integer
dim major, minor, first, second as Integer
if instr(f.name, ".exe")= 0 then return ""
if f.length< 3000000 then return ""
Declare Function GetFileVersionInfoA lib "Version" _
( fileName as CString, ignored as Integer, len as Integer, buffer as Ptr) _
as Integer
Declare Function GetFileVersionInfoSizeA lib "Version" _
( fileName as CString, ByRef ignored as Integer ) as Integer
Declare Function VerQueryValueA lib "Version" _
( info as Ptr, subBlock as CString, value as Ptr, ByRef len as Integer ) _
as Integer
totalSize = GetFileVersionInfoSizeA( f.AbsolutePath, toss )
info = new MemoryBlock( totalSize )
call GetFileVersionInfoA( f.AbsolutePath, 0, totalSize, info )
passIn = new MemoryBlock( 4 )
call VerQueryValueA( info, "\", passIn, buffLen )
fixedInfo = passIn.Ptr( 0 )
highBits = fixedInfo.Long( 8 )
lowBits = fixedInfo.Long( 12 )
major = Bitwise.ShiftRight( highBits, 16 )
minor = Bitwise.BitAnd( highBits, &hFFFF )
first = Bitwise.ShiftRight( lowBits, 16 )
second = Bitwise.BitAnd( lowBits, &hFFFF )
version= Str( major ) + "." + Str( minor ) + "." + _
Str( first ) + "." + Str( second )
return version
End Function
Probably Aaron way back when since its been in the WFS forever
or use plugin class: WindowsFileVersionMBS
https://www.monkeybreadsoftware.net/class-windowsfileversionmbs.shtml
Many thanks