GetFileVersion: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Updated by user: Instructor (talk, contrib).)
Line 7: Line 7:
: http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost
: http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost


If function used without header then put function in script before call it  
If a function is used without an header, you should put the function below in your script before calling it.


== The Function ==
== The Function ==
Line 15: Line 15:
                             GetFileVersion
                             GetFileVersion
____________________________________________________________________________
____________________________________________________________________________
Thanks KiCHiK (Based on his example for command "GetDLLVersion")




Line 21: Line 23:


Syntax:
Syntax:
${GetFileVersion} "[Executable]" $var


Push "[Executable]"   ; [Executable]
"[Executable]"     ; Executable file (*.exe *.dll ...)
                      ;  Executable file (*.exe *.dll ...)
$var               ; Result: Version number
                      ;
Call GetFileVersion  ; Call function
                      ;
Pop $var             ; version




Line 33: Line 32:
-Error flag if file isn't exist
-Error flag if file isn't exist
-Error flag if file isn't contain version information
-Error flag if file isn't contain version information




Example:
Example:
Section
Section
Push "C:\ftp\program.exe"
${GetFileVersion} "C:\ftp\program.exe" $R0
Call GetFileVersion
; $R0="1.1.0.12"
Pop $R0    ; $R0="1.1.0.12"
SectionEnd*/
SectionEnd*/




;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
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 52: Line 60:
Push $5
Push $5
Push $6
Push $6
ClearErrors


GetDllVersion '$0' $1 $2
GetDllVersion '$0' $1 $2

Revision as of 09:39, 24 June 2005

Author: Instructor (talk, contrib)


Links

Latest version of headers "nsh.zip"
http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost

If a function is used without an header, you should put the function below in your script before calling it.

The Function

/*
____________________________________________________________________________
 
                            GetFileVersion
____________________________________________________________________________
 
Thanks KiCHiK (Based on his example for command "GetDLLVersion")
 
 
Gets the version information from executable file.
 
 
Syntax:
${GetFileVersion} "[Executable]" $var
 
"[Executable]"      ; Executable file (*.exe *.dll ...)
$var                ; Result: Version number
 
 
Note:
-Error flag if file isn't exist
-Error flag if file isn't contain version information
 
 
 
Example:
Section
	${GetFileVersion} "C:\ftp\program.exe" $R0
	; $R0="1.1.0.12"
SectionEnd*/
 
 
;---------------------------------------------------------------------------
 
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 / 0x00010000
	IntOp $4 $1 & 0x0000FFFF
	IntOp $5 $2 / 0x00010000
	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