GetFileVersion: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.) |
No edit summary |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Instructor}} | |||
{{User:Instructor/Headers/Template}} | |||
== | == Function Description== | ||
<highlight-nsis> | |||
<highlight-nsis> | |||
____________________________________________________________________________ | ____________________________________________________________________________ | ||
GetFileVersion | GetFileVersion | ||
____________________________________________________________________________ | ____________________________________________________________________________ | ||
Thanks KiCHiK (Based on his example for command "GetDLLVersion") | |||
Get version information from executable file. | |||
Syntax: | Syntax: | ||
${GetFileVersion} "[Executable]" $var | |||
"[Executable]" ; Executable file (*.exe *.dll ...) | |||
$var ; Result: Version number | |||
Note: | Note: | ||
-Error flag if file | -Error flag if file doesn't exist | ||
-Error flag if file | -Error flag if file doesn't contain version information | ||
</highlight-nsis> | |||
<b>Example:</b> | |||
<highlight-nsis>Section | |||
${GetFileVersion} "C:\ftp\program.exe" $R0 | |||
; $R0="1.1.0.12" | |||
SectionEnd | |||
</highlight-nsis> | |||
== Function Code == | |||
<highlight-nsis> | |||
Function GetFileVersion | Function GetFileVersion | ||
!define GetFileVersion `!insertmacro GetFileVersionCall` | |||
!macro GetFileVersionCall _FILE _RESULT | |||
Push `${_FILE}` | |||
Call GetFileVersion | |||
Pop ${_RESULT} | |||
!macroend | |||
Exch $0 | Exch $0 | ||
Push $1 | Push $1 | ||
Line 48: | Line 57: | ||
Push $5 | Push $5 | ||
Push $6 | Push $6 | ||
ClearErrors | |||
GetDllVersion '$0' $1 $2 | GetDllVersion '$0' $1 $2 | ||
IfErrors error | IfErrors error | ||
IntOp $3 $1 | IntOp $3 $1 >> 16 | ||
IntOp $3 $3 & 0x0000FFFF | |||
IntOp $4 $1 & 0x0000FFFF | IntOp $4 $1 & 0x0000FFFF | ||
IntOp $5 $2 | IntOp $5 $2 >> 16 | ||
IntOp $5 $5 & 0x0000FFFF | |||
IntOp $6 $2 & 0x0000FFFF | IntOp $6 $2 & 0x0000FFFF | ||
StrCpy $0 '$3.$4.$5.$6' | StrCpy $0 '$3.$4.$5.$6' | ||
Line 73: | Line 85: | ||
</highlight-nsis> | </highlight-nsis> | ||
[[Category:Disk, Path & File Functions]] |
Latest revision as of 17:38, 26 June 2007
Author: Instructor (talk, contrib) |
Page for NSIS 2.07 and below users
You can use the latest version of headers (recommended) or the following function code (put the function code in your script before calling it)
Function Description
____________________________________________________________________________ GetFileVersion ____________________________________________________________________________ Thanks KiCHiK (Based on his example for command "GetDLLVersion") Get version information from executable file. Syntax: ${GetFileVersion} "[Executable]" $var "[Executable]" ; Executable file (*.exe *.dll ...) $var ; Result: Version number Note: -Error flag if file doesn't exist -Error flag if file doesn't contain version information
Example:
Section ${GetFileVersion} "C:\ftp\program.exe" $R0 ; $R0="1.1.0.12" SectionEnd
Function Code
Function GetFileVersion !define GetFileVersion `!insertmacro GetFileVersionCall` !macro GetFileVersionCall _FILE _RESULT Push `${_FILE}` Call GetFileVersion Pop ${_RESULT} !macroend Exch $0 Push $1 Push $2 Push $3 Push $4 Push $5 Push $6 ClearErrors GetDllVersion '$0' $1 $2 IfErrors error IntOp $3 $1 >> 16 IntOp $3 $3 & 0x0000FFFF IntOp $4 $1 & 0x0000FFFF IntOp $5 $2 >> 16 IntOp $5 $5 & 0x0000FFFF IntOp $6 $2 & 0x0000FFFF StrCpy $0 '$3.$4.$5.$6' goto end error: SetErrors StrCpy $0 '' end: Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 FunctionEnd