Here is a small example.
Code: Select all
msgbox( fileversioninfo( a_ahkpath, "FileDescription" ))
; Original version: https://autohotkey.com/board/topic/59496-filegetversioninfo-aw/
fileversioninfo( file :="", fileinfo :="" ) {
local char := ( a_isunicode ? "W" : "A" )
local fsize := dllcall( "Version\GetFileVersionInfoSize" char, "str", file, "uint", 0 )
if not fsize
return -1
local trans
local infoptr := 0
local translation := 0
local infoptr := 0
local fvi := bufferalloc( fsize, 0 )
varsetcapacity( trans, ( a_isunicode ? 16 : 8 ))
dllcall( "Version\GetFileVersionInfo" char, "str", file, "int", 0, "uint", fsize, "uint", fvi.ptr )
if not dllcall( "Version\VerQueryValue" char, "uint", fvi.ptr, "str", "\VarFileInfo\Translation", "uint*", translation, "uint", 0 )
return -2
if not dllcall( "msvcrt\swprintf", "str", trans, "str", "%08X", "uint", numget( translation +0 ), "cdecl int" )
return -3
local subblock := "\StringFileInfo\" substr( trans, -4 ) substr( trans, 1, 4 ) "\" fileinfo
if not dllcall( "Version\VerQueryValue" char, "uint", fvi.ptr, "str", subblock, "uint*", infoptr, "uint", 0 )
return -4
local info := (
a_isunicode
? strget( infoptr, dllcall( "kernel32\lstrlen" char, "uint", infoptr ))
: dllcall( "Kernel32\MulDiv", "uint", infoptr, "int", 1, "int", 1, "str" )
)
return info
}