Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[LIB] Get File Version Information


  • Please log in to reply
1 reply to this topic
ABCza
  • Members
  • 132 posts
  • Last active: Jan 04 2015 01:02 AM
  • Joined: 03 Jun 2008
Hola bro,
I wrote this function to extract the Version Information for Windows Executables. It's written for Basic.

; ------------------------------------------------------------------------------
; Function .....: FileVerInfo
; Description ..: Return Version Information for the selected file
; Parameters ...: sFile      - Path to the file
; ..............: sVerString - Pipe-separated list of the properties to retrieve
; ..............:              If empty, all properties will be retrieved
; Return .......: String with properties on success, 0 on error
; AHK Version ..: AutoHotkey 1.0.48.5
; Author .......: Cyruz - http://ciroprincipe.info
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/
; Changelog ....: Nov. 17, 2012 - ver 0.1 - First revision
; ------------------------------------------------------------------------------
FileVerInfo(sFile, sVerString="") {
    
    sVerString := (sVerString) ? sVerString : "Comments|CompanyName|FileDescription|FileVersion|InternalName|LegalCopyright|LegalTrademarks|OriginalFilename|ProductName|ProductVersion|PrivateBuild|SpecialBuild"

    If (! nSize := DllCall( "Version.dll\GetFileVersionInfoSizeA"
                          ,  Str,  sFile
                          ,  UInt, 0 ))
        Return 0

    VarSetCapacity(cBuf, nSize)
    If (! DllCall( "Version.dll\GetFileVersionInfoA"
                 ,  Str,  sFile
                 ,  UInt, 0
                 ,  UInt, nSize
                 ,  UInt, &cBuf ))
        Return 0

    If (! DllCall( "Version.dll\VerQueryValueA"
                 ,  UInt,  &cBuf
                 ,  Str,   "\\VarFileInfo\\Translation"
                 ,  UIntP, pAddrVerBuf
                 ,  UIntP, nVerBufSize ))
        Return 0
        
    VarSetCapacity(sLangCodePg, 8)
    DllCall( "msvcrt\sprintf"
           ,  Str,   sLangCodePg
           ,  Str,   "%04X%04X"
           ,  Short, NumGet(pAddrVerBuf+0, 0, "Short")
           ,  Short, NumGet(pAddrVerBuf+0, 2, "Short") )

    StringSplit, sVerString, sVerString, |    
    Loop, %sVerString0%
    {
        DllCall( "Version.dll\VerQueryValueA"
               ,  UChar, &cBuf
               ,  Str,   "\\StringFileInfo\\" . sLangCodePg . "\\" . sVerString%A_Index%
               ,  UIntP, pAddrVerBuf
               ,  UIntP, nVerBufSize )

        VarSetCapacity(cVerBuf, nVerBufSize)
        DllCall( "Kernel32.dll\lstrcpyn"
               ,  Str,  cVerBuf
               ,  UInt, pAddrVerBuf
               ,  Int,  nVerBufSize )
        
        RetString .= sVerString%A_Index% . "|" . cVerBuf . "|"
    }

    Return SubStr(RetString, 1, -1)
}

All my scripts/snippets are released under the WTFPL: http://sam.zoy.org/wtfpl/COPYING

zoraxe
  • Members
  • 25 posts
  • Last active: Dec 14 2012 10:29 AM
  • Joined: 17 Aug 2012

Hola bro,
I wrote this function to extract the Version Information for Windows Executables. It's written for Basic.

Download here: https://github.com/c...FileVerInfo.ahk


Nice! Will be useful.