On Windows I use this
f=GetFolderItem("FileToCheck")
if f<>nil and f.Exists then
strLocalVersion=Win32DeclareLibrary.GetVersion(f)
else
strLocalVersion=""
end if
Win32DeclareLibrary is part of Aaron's Win32 Functionality Suite.
This the content of the function GetVersion(f As FolderItem) As String
#if TargetWin32
' Get the folder item to inspect
'dim f as FolderItem
'f=SystemFolder
'f = f.Child( "MSJet40.dll" )
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
' Get the total size of the version information
' structure. We only care about a small part of it
dim totalSize, toss as Integer
totalSize = GetFileVersionInfoSizeA( f.AbsolutePath, toss )
' Get all of the version information back
dim info as MemoryBlock
info = new MemoryBlock( totalSize )
call GetFileVersionInfoA( f.AbsolutePath, 0, totalSize, info )
Dim passIn, fixedInfo as MemoryBlock
Dim buffLen as Integer
' We need to get a pointer to a pointer. This is
' because the OS will allocate the memory that
' our pointer will point to.
passIn = new MemoryBlock( 4 )
' We're going to ask for the root information, which
' will give us back a structure called a VS_FIXEDFILEINFO
' You can look up the structure information if you'd like
call VerQueryValueA( info, "\", passIn, buffLen )
' Remember, we're pointing at a pointer to the information
' so get a memoryblock that points to the actual
' information
fixedInfo = passIn.Ptr( 0 )
' We're interested in the file version information
dim highBits, lowBits as Integer
highBits = fixedInfo.Long( 8 )
lowBits = fixedInfo.Long( 12 )
' The version information is like this. The high 2 bytes
' of highBits is the major version. The low 2 bytes
' of highBits is the minor version. The high 2 bytes
' of lowBits is the 1st revision number, and the low
' 2 bytes of lowBits is the 2nd revision number.
dim major, minor, first, second as Integer
major = Bitwise.ShiftRight( highBits, 16 )
minor = Bitwise.BitAnd( highBits, &hFFFF )
first = Bitwise.ShiftRight( lowBits, 16 )
second = Bitwise.BitAnd( lowBits, &hFFFF )
' Let's report back the file information
dim talkString as String
talkString = Str( major ) + "." + Str( minor ) + "." + _
Str( first ) + "." + Str( second )
Return talkString
#endif
Exception
Return ""
Thank Aaron for me
Dirk Cleenwerck
Chief Programmer
Useitgroup NV
Guyren Howe schreef:
> Is there any way to get version information for files on Mac and
> Windows?
>
> Regards,
>
> Guyren G Howe
> Relevant Logic LLC
>
> guyren-at-relevantlogic.com ~ http://relevantlogic.com
>
> REALbasic, PHP, Ruby/Rails, Python programming
> PostgreSQL, MySQL database design and consulting
> Technical writing and training
>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
>
>
>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>