Lua:getFileVersion

From Cheat Engine
Jump to navigation Jump to search

<> Reference

function getFileVersion(pathtofile) : integer, table

Returns the 64-bit file version of the specified file, as well as a table containing the version split into separate fields.

The returned table contains the major, minor, release, and build parts of the file version.

Function Parameters

Parameter Type Description
pathtofile String The path to the file whose version information should be retrieved.

Returns

integer, table — The 64-bit file version, followed by a table containing the split version fields.

Return Table Fields

Field Type Description
major Integer The major version number.
minor Integer The minor version number.
release Integer The release version number.
build Integer The build version number.

Examples

local version, versionInfo = getFileVersion("C:\\\\Windows\\\\System32\\\\kernel32.dll")

print("Version: " .. tostring(version))

if versionInfo ~= nil then
  print("Major: " .. tostring(versionInfo.major))
  print("Minor: " .. tostring(versionInfo.minor))
  print("Release: " .. tostring(versionInfo.release))
  print("Build: " .. tostring(versionInfo.build))
end
local version, versionInfo = getFileVersion("C:\\\\Windows\\\\System32\\\\kernel32.dll")

if versionInfo ~= nil then
  local versionString = string.format(
    "%d.%d.%d.%d",
    versionInfo.major,
    versionInfo.minor,
    versionInfo.release,
    versionInfo.build
  )

  print("File version: " .. versionString)
end

See Also

Main Pages