Function to Check if a DLL in the System is older than you needs
From NSIS Wiki
Jump to navigationJump to search
Author: KiKoLo (talk, contrib) |
Description
This Function Checks the version of the dll, and if the version is lesser than you require, it returns the segment:
- if the installed is equal or newer, returns 0
- if the installed is older:
- if the major version is lesser it returns 1
- if the minor version is lesser it returns 2
- if the revision version is lesser it returns 3
- if the rebuild version is lesser it returns 4
See You
KiKoLo
The Function
; ; FCheckVersion ; ; Check a Dll and informs if is older than the program need. ; ; Usage: ; ... ; Push "2300" ;Rebuild ; Push "4817" ;Revision ; Push "81" ;Minor ; Push "5" ;Mayor ; Push "$SYSDIR\comctl32b.dll" ;DLLFullPath ; Call FCheckVersion ; Pop $R0 ; IntCmp $R0 0 +3 +3 ; MessageBox MB_YESNO|MB_ICONSTOP|MB_TOPMOST|MB_DEFBUTTON2 "Error!!! $\nContinue?" IDYES +2 ; Quit ; ... ; Function FCheckVersion Pop $1 ;DLLFullPath Pop $2 ;Mayor Pop $3 ;Minor Pop $4 ;Revision Pop $5 ;Rebuild GetDllVersion "$1" $R0 $R1 IntOp $R2 $R0 / 0x00010000 IntOp $R3 $R0 & 0x0000FFFF IntOp $R4 $R1 / 0x00010000 IntOp $R5 $R1 & 0x0000FFFF StrCpy $0 "0" IntCmp $2 $R2 +1 lbl_exit lbl_mayor IntCmp $3 $R3 +1 lbl_exit lbl_minor IntCmp $4 $R4 +1 lbl_exit lbl_revision IntCmp $5 $R5 lbl_exit lbl_exit lbl_rebuild lbl_rebuild: IntOp $0 $0 + 1 lbl_revision: IntOp $0 $0 + 1 lbl_minor: IntOp $0 $0 + 1 lbl_mayor: IntOp $0 $0 + 1 lbl_exit: Push $0 ClearErrors FunctionEnd