Skip to content

Commit

Permalink
windwos installer updated to skip WinPcap if same or newer version is…
Browse files Browse the repository at this point in the history
… installed
  • Loading branch information
seuffert committed May 12, 2011
1 parent 7b4b91f commit 2a1606c
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
84 changes: 84 additions & 0 deletions XBSlink Installer/VersionCompare.nsh
@@ -0,0 +1,84 @@
Function VersionCompare
!define VersionCompare `!insertmacro VersionCompareCall`

!macro VersionCompareCall _VER1 _VER2 _RESULT
Push `${_VER1}`
Push `${_VER2}`
Call VersionCompare
Pop ${_RESULT}
!macroend

Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7

begin:
StrCpy $2 -1
IntOp $2 $2 + 1
StrCpy $3 $0 1 $2
StrCmp $3 '' +2
StrCmp $3 '.' 0 -3
StrCpy $4 $0 $2
IntOp $2 $2 + 1
StrCpy $0 $0 '' $2

StrCpy $2 -1
IntOp $2 $2 + 1
StrCpy $3 $1 1 $2
StrCmp $3 '' +2
StrCmp $3 '.' 0 -3
StrCpy $5 $1 $2
IntOp $2 $2 + 1
StrCpy $1 $1 '' $2

StrCmp $4$5 '' equal

StrCpy $6 -1
IntOp $6 $6 + 1
StrCpy $3 $4 1 $6
StrCmp $3 '0' -2
StrCmp $3 '' 0 +2
StrCpy $4 0

StrCpy $7 -1
IntOp $7 $7 + 1
StrCpy $3 $5 1 $7
StrCmp $3 '0' -2
StrCmp $3 '' 0 +2
StrCpy $5 0

StrCmp $4 0 0 +2
StrCmp $5 0 begin newer2
StrCmp $5 0 newer1
IntCmp $6 $7 0 newer1 newer2

StrCpy $4 '1$4'
StrCpy $5 '1$5'
IntCmp $4 $5 begin newer2 newer1

equal:
StrCpy $0 0
goto end
newer1:
StrCpy $0 1
goto end
newer2:
StrCpy $0 2

end:
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
13 changes: 13 additions & 0 deletions XBSlink Installer/XBSlink_installer_MUI2.nsi
Expand Up @@ -5,6 +5,7 @@
;--------------------------------
!include "MUI2.nsh"
!include "FileFunc.nsh"
!include "VersionCompare.nsh"
!system "xbslink_version_info.exe"
!include "XBSlink_version.txt"
;--------------------------------
Expand Down Expand Up @@ -102,11 +103,23 @@ Section "Start Menu Shortcuts" StartMenuShortcuts

SectionEnd

Var WINPCAP_NAME ; DisplayName from WinPcap installation
Var WINPCAP_VERSION ; DisplayVersion from WinPcap installation

;--------------------------------
Section "WinPCap Capture Library" WinPCap
SetOutPath $TEMP
File "WinPcap_4_1_2.exe"
ReadRegStr $WINPCAP_NAME HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" "DisplayName"
IfErrors lbl_winpcap_do_install
ReadRegStr $WINPCAP_VERSION HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" "DisplayVersion"
StrCmp $WINPCAP_VERSION "" lbl_winpcap_do_install ; WinPcap is really old(?) or installed improperly.
${VersionCompare} $WINPCAP_VERSION "4.1.0.2001" $1 ; WinPcap 4.1.2
StrCmp $1 "1" lbl_winpcap_do_install
goto lbl_winpcap_dont_install
lbl_winpcap_do_install:
ExecWait '"$TEMP\WinPcap_4_1_2.exe"'
lbl_winpcap_dont_install:
Delete "$TEMP\WinPcap_4_1_2.exe"
SectionEnd
;--------------------------------
Expand Down

0 comments on commit 2a1606c

Please sign in to comment.