GetFileVersion: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
m (Updated author and download links, and changed format of some pages.)
Line 73: Line 73:
</highlight-nsis>
</highlight-nsis>


 
Page author: [[User:Instructor|Instructor]]
Page author: Instructor

Revision as of 12:45, 23 April 2005

Links

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

If function used without header then put function in script before call it

The Function

/*
____________________________________________________________________________
 
                            GetFileVersion
____________________________________________________________________________
 
 
Gets the version information from executable file.
 
 
Syntax:
 
Push "[Executable]"   ; [Executable]
                      ;   Executable file (*.exe *.dll ...)
                      ;
Call GetFileVersion   ; Call function
                      ;
Pop $var              ; version
 
 
Note:
-Error flag if file isn't exist
-Error flag if file isn't contain version information
 
 
Example:
Section
	Push "C:\ftp\program.exe"
	Call GetFileVersion
	Pop $R0     ; $R0="1.1.0.12"
SectionEnd*/
 
 
;---------------------------------------------------------------------------
Function GetFileVersion
	Exch $0
	Push $1
	Push $2
	Push $3
	Push $4
	Push $5
	Push $6
 
	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

Page author: Instructor