pop $R1
FunctionEnd
+Var OLD_UNINSTALLER
+Var OLD_DISPLAYNAME
+
Function .onInit
+ ; Copied from http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new
+ ReadRegStr $OLD_UNINSTALLER HKLM \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark" \
+ "UninstallString"
+ StrCmp $OLD_UNINSTALLER "" done
+
+ ReadRegStr $OLD_DISPLAYNAME HKLM \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark" \
+ "DisplayName"
+ StrCmp $OLD_DISPLAYNAME "" done
+
+ MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
+ "$OLD_DISPLAYNAME is already installed. $\n$\nClick `OK` to remove it \
+ or `Cancel` to cancel this upgrade." \
+ IDOK uninst
+ Abort
+
+;Run the uninstaller
+uninst:
+ ClearErrors
+ ExecWait $OLD_UNINSTALLER
+
+done:
;Extract InstallOptions INI files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "AdditionalTasksPage.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "WinpcapPage.ini"
Function myShowCallback
-; Uinstall old Wireshark first
-; XXX - doesn't work, but kept here for further experiments
-;ReadRegStr $WIRESHARK_UNINSTALL HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark" "UninstallString"
-;IfErrors lbl_wireshark_notinstalled ;if RegKey is unavailable, WinPcap is not installed
-;MessageBox MB_YESNO|MB_ICONQUESTION "Uninstall the old Wireshark version first (recommended)?"
-; Hide the installer while uninstalling
-;GetDlgItem $0 $HWNDPARENT 1
-;FindWindow $0 "#32770" "" $HWNDPARENT
-;MessageBox MB_OK "Window $0"
-;ShowWindow $0 ${SW_HIDE}
-;HideWindow
-;ExecWait '$WIRESHARK_UNINSTALL' $0
-;DetailPrint "WinPcap uninstaller returned $0"
-;GetDlgItem $0 $HWNDPARENT 1
-;ShowWindow $0 ${SW_SHOW}
-;MessageBox MB_OK "Uninstalled"
-;lbl_wireshark_notinstalled:
-
-
; Get the Windows version
Call GetWindowsVersion
Pop $R0 ; Windows Version