; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "AVStoDVD"
!define PRODUCT_EXENAME "${PRODUCT_NAME}.exe"
!define PRODUCT_MAJOR "2"
!define PRODUCT_MINOR "8"
!define PRODUCT_REVISION "5"
!define PRODUCT_BUILD "Alpha 161014"
!define PRODUCT_VERSION "${PRODUCT_MAJOR}.${PRODUCT_MINOR}.${PRODUCT_REVISION}"
!define PRODUCT_PUBLISHER "MrC"
!define PRODUCT_WEB_SITE "http://sites.google.com/site/avstodvdmain"
!define PRODUCT_INST_ROOT_KEY "HKCU"
!define PRODUCT_INST_KEY "Software\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

; Compression
SetCompressor /FINAL /SOLID lzma

; Set Admin rights
RequestExecutionLevel Admin

; MUI 1.67 compatible ------
!include "${NSISDIR}\Include\Library.nsh"
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${PRODUCT_NAME}.ico"
!define MUI_UNICON ".\!Stuff\AVStoDVD_Uninstall.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\!Stuff\AVStoDVD_Splash_164x314.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\!Stuff\AVStoDVD_Splash_150x57.bmp"
!define MUI_HEADERIMAGE_UNBITMAP ".\!Stuff\AVStoDVD_Splash_150x57.bmp"
!define MUI_HEADERIMAGE_RIGHT

; Welcome page
!define MUI_WELCOMEPAGE_TITLE "Welcome to the ${PRODUCT_NAME} ${PRODUCT_VERSION} Install Wizard"
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${PRODUCT_NAME} ${PRODUCT_VERSION}, a flexible tool to convert various media formats to DVD compliant streams and burn them into a highly compatible multiple tracks DVD.\r\n\r\n$_CLICK"
!insertmacro MUI_PAGE_WELCOME

; License page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE ".\License.txt"

; Components page
!insertmacro MUI_PAGE_COMPONENTS
LangString DESC_SEC01 ${LANG_English} "Install AVStoDVD core program and all required tools."
LangString DESC_SEC02 ${LANG_English} "Install AviSynth 2.6.0 (unchecked if already installed). Required for Video and Audio encoding."
LangString DESC_SEC03 ${LANG_English} "Install LAV Filters 0.68 (unchecked if already installed). Suggested media splitter and video/audio codecs suite."
LangString DESC_SEC04 ${LANG_English} "Install and register all required ActiveX Controls (unchecked if already installed)"

; Directory page
!insertmacro MUI_PAGE_DIRECTORY

; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${PRODUCT_NAME}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP

; Instfiles page
!insertmacro MUI_PAGE_INSTFILES

; Finish page
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_NAME}.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Run ${PRODUCT_NAME} ${PRODUCT_VERSION}"
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\ReadMe.txt"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_LINK "Visit ${PRODUCT_NAME} site for the latest news and support"
!define MUI_FINISHPAGE_LINK_LOCATION ${PRODUCT_WEB_SITE}
!define MUI_PAGE_CUSTOMFUNCTION_PRE 'FinishPre'
!define MUI_PAGE_CUSTOMFUNCTION_SHOW 'FinishShow'
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

BrandingText "${PRODUCT_NAME} ${PRODUCT_VERSION} Setup"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
Outfile "${PRODUCT_NAME}_${PRODUCT_MAJOR}${PRODUCT_MINOR}${PRODUCT_REVISION}${PRODUCT_BUILD}_Install.exe"
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
InstallDirRegKey "${PRODUCT_INST_ROOT_KEY}" "${PRODUCT_INST_KEY}" "AppPath"
ShowInstDetails show
ShowUnInstDetails show

Section "!${PRODUCT_NAME} package" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite on
  File ".\AVStoDVD.exe"
  File ".\AVStoDVD.ico"
  File ".\History.txt"
  File ".\License.txt"
  File ".\ReadMe.txt"
  SetOutPath "$INSTDIR\ac3fix"
  File ".\ac3fix\*.*"
  SetOutPath "$INSTDIR\Aften"
  File ".\Aften\*.*"
  SetOutPath "$INSTDIR\AVSMeter"
  File /r ".\AVSMeter\*.*"
  SetOutPath "$INSTDIR\BatchMux"
  File /r ".\BatchMux\*.*"
  SetOutPath "$INSTDIR\DGIndex"
  File ".\DGIndex\*.*"
  SetOutPath "$INSTDIR\DGPulldown"
  File ".\DGPulldown\*.*"
  SetOutPath "$INSTDIR\Docs"
  File /x "*.db"  ".\Docs\*.*"
  SetOutPath "$INSTDIR\FFmpeg"
  File /r ".\FFmpeg\*.*"
  SetOutPath "$INSTDIR\Graphics"
  File ".\Graphics\*.*"
  SetOutPath "$INSTDIR\GraphStudio"
  File ".\GraphStudio\*.*"
  SetOutPath "$INSTDIR\HCenc"
  File ".\HCenc\*.*"
  SetOutPath "$INSTDIR\Lang"
  File ".\Lang\*.*"
  SetOutPath "$INSTDIR\Lib"
  File /x "mscomctl.ocx" ".\Lib\*.*"
  SetOutPath "$INSTDIR\Menu"
  File /r /x "*.db" ".\Menu\*.*"
  SetOutPath "$INSTDIR\MKVtoolNix"
  File /r ".\MKVtoolNix\*.*"
  SetOutPath "$INSTDIR\Mplex"
  File ".\Mplex\*.*"
  SetOutPath "$INSTDIR\MuxMan"
  File ".\MuxMan\*.*"
  SetOutPath "$INSTDIR\SetACL"
  File ".\SetACL\*.*"
  SetOutPath "$INSTDIR\Skins"
  File /r /x "*.db" ".\Skins\*.*"
  SetOutPath "$INSTDIR\SubtitleCreator"
  File /r ".\SubtitleCreator\*.*"
  SetOutPath "$INSTDIR\VobSub"
  File ".\VobSub\*.*"
  SetOutPath "$INSTDIR\Wavi"
  File /r ".\Wavi\*.*"

; Shortcuts
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  SetShellVarContext current
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_EXENAME}"
  CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_EXENAME}" "" "$INSTDIR\${PRODUCT_NAME}.ico"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\AVStoDVD Help.lnk" "$INSTDIR\Docs\AVStoDVD_Help.chm"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\History.lnk" "$INSTDIR\History.txt"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\License.lnk" "$INSTDIR\License.txt"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\ReadMe.lnk" "$INSTDIR\ReadMe.txt"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DVD Menu Templates.lnk" "$INSTDIR\Menu\Templates"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\DGIndex"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DGIndex\DGIndex.lnk" "$INSTDIR\DGIndex\DGIndex.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DGIndex\DGIndex Manual.lnk" "$INSTDIR\DGIndex\DGIndexManual.html"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DGIndex\DGDecode Manual.lnk" "$INSTDIR\DGIndex\DGDecodeManual.html"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\DGPulldown"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DGPulldown\DGPulldown.lnk" "$INSTDIR\DGPulldown\DGPulldown.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DGPulldown\ReadMe.lnk" "$INSTDIR\DGPulldown\DGPulldown.txt"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\GraphStudio"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\GraphStudio\GraphStudio.lnk" "$INSTDIR\GraphStudio\GraphStudio0320.exe"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\HCenc"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\HCenc\HCenc.lnk" "$INSTDIR\HCenc\HCenc.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\HCenc\HCenc Manual.lnk" "$INSTDIR\HCenc\HC023.pdf"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\MKVtoolNix"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\MKVtoolNix\MKVmerge GUI.lnk" "$INSTDIR\MKVtoolNix\mmg.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\MKVtoolNix\MKVtoolNix WebPage.lnk" "$INSTDIR\MKVtoolNix\MKVToolNix.url"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\MKVtoolNix\MKVtoolNix ReadMe.lnk" "$INSTDIR\MKVtoolNix\doc\README.txt"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\MuxMan"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\MuxMan\MuxMan.lnk" "$INSTDIR\MuxMan\MuxMan.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\MuxMan\ReadMe.lnk" "$INSTDIR\MuxMan\readme.txt"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\SubtitleCreator"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\SubtitleCreator\SubtitleCreator.lnk" "$INSTDIR\SubtitleCreator\SubtitleCreator.exe"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\SubtitleCreator\User Guide.lnk" "$INSTDIR\SubtitleCreator\Documentation\SubtitleCreator user guide.pdf"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\SubtitleCreator\ReadMe.lnk" "$INSTDIR\SubtitleCreator\Documentation\readme.txt"
  !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Section /o "AviSynth 2.6.0" SEC02
  SetOutPath "$INSTDIR\AviSynth"
  File ".\AviSynth\Avisynth_260.exe"
  ExecWait "$INSTDIR\AviSynth\Avisynth_260.exe" $0
SectionEnd

Section /o "LAV Filters 0.68" SEC03
  SetOutPath "$INSTDIR\LAVFilters"
  File ".\LAVFilters\LAVFilters-0.68.exe"
  ExecWait "$INSTDIR\LAVFilters\LAVFilters-0.68.exe" $0
SectionEnd

Section /o "ActiveX Controls" SEC04
  SetOutPath "$INSTDIR\Lib"
  File ".\Lib\mscomctl.ocx"
  !insertmacro InstallLib REGDLL NOTSHARED REBOOT_NOTPROTECTED ".\Lib\mscomctl.ocx" $SYSDIR\mscomctl.ocx $SYSDIR
SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_SEC01)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(DESC_SEC02)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(DESC_SEC03)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $(DESC_SEC04)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Section -AdditionalIcons
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
  !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXENAME}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"

  WriteRegStr HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$INSTDIR\${PRODUCT_EXENAME}" ""

  WriteRegStr HKCR ".a2d" "" "A2DFile"
  WriteRegStr HKCR "A2DFile" "" "AVStoDVD Project"
  WriteRegStr HKCR "A2DFile\DefaultIcon" "" "$INSTDIR\${PRODUCT_EXENAME},0"
  WriteRegStr HKCR "A2DFile\shell" "" "open"
  WriteRegStr HKCR "A2DFile\shell\open" "" "Open ${PRODUCT_NAME} Project"
  WriteRegStr HKCR "A2DFile\shell\open\command" "" '"$INSTDIR\${PRODUCT_EXENAME}" "%1"'
SectionEnd

Section Uninstall
  !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
  Delete "$DESKTOP\AVStoDVD.lnk"
  SetShellVarContext current
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\DGPulldown"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\DGIndex"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\GraphStudio"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\HCenc"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\MKVtoolNix"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\MuxMan"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\SubtitleCreator"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP"
  SetShellVarContext all
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\DGPulldown"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\DGIndex"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\GraphStudio"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\HCenc"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\MKVtoolNix"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\Mplex"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\MuxMan"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\SetACL"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP\SubtitleCreator"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP"

  RMDir /r "$INSTDIR\Wavi"
  RMDir /r "$INSTDIR\VobSub"
  RMDir /r "$INSTDIR\SubtitleCreator"
  RMDir /r "$INSTDIR\Skins\Default"
  RMDir /r "$INSTDIR\Skins\Classic"
  Delete "$INSTDIR\Skins\*.*"
  RMDir "$INSTDIR\Skins"
  RMDir /r "$INSTDIR\SetACL"
  RMDir /r "$INSTDIR\MuxMan"
  RMDir /r "$INSTDIR\MKVtoolNix"
  RMDir /r "$INSTDIR\Menu\HL Formats"
  RMDir /r "$INSTDIR\Menu\HL Colors"
  RMDir /r "$INSTDIR\Menu\Templates\Blue Rain"
  RMDir /r "$INSTDIR\Menu\Templates\Collage"
  RMDir /r "$INSTDIR\Menu\Templates\Menu in Black"
  Delete "$INSTDIR\Menu\Templates\*.*"
  RMDir "$INSTDIR\Menu\Templates"
  Delete "$INSTDIR\Menu\*.*"
  RMDir "$INSTDIR\Menu"
  RMDir /r "$INSTDIR\Lib"
  RMDir /r "$INSTDIR\LAVFilters"
  RMDir /r "$INSTDIR\Lang"
  RMDir /r "$INSTDIR\HCenc"
  RMDir /r "$INSTDIR\GraphStudio"
  RMDir /r "$INSTDIR\Graphics"
  RMDir /r "$INSTDIR\FFmpeg"
  RMDir /r "$INSTDIR\Docs"
  RMDir /r "$INSTDIR\DGPulldown"
  RMDir /r "$INSTDIR\DGIndex"
  RMDir /r "$INSTDIR\BatchMux"
  RMDir /r "$INSTDIR\AVSMeter"
  RMDir /r "$INSTDIR\Aften"
  RMDir /r "$INSTDIR\ac3fix"
  RMDir /r "$INSTDIR\AviSynth"
  Delete "$INSTDIR\*.*"
  RMDir "$INSTDIR"

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"

  DeleteRegKey HKCR ".a2d"
  DeleteRegKey HKCR "A2DFile\shell\open\command"
  DeleteRegKey HKCR "A2DFile\shell\open"
  DeleteRegKey HKCR "A2DFile\shell"
  DeleteRegKey HKCR "A2DFile\DefaultIcon"
  DeleteRegKey HKCR "A2DFile"

  DeleteRegValue HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$INSTDIR\${PRODUCT_EXENAME}"

  ;SetAutoClose true
SectionEnd

Function .onInit

  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME}_${PRODUCT_MAJOR}${PRODUCT_MINOR}${PRODUCT_REVISION}${PRODUCT_BUILD}_Install.exe") i .r1 ?e'
  Pop $R0
  StrCmp $R0 0 +3
    MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
    Abort

  IntOp $R1 ${SF_SELECTED} | ${SF_RO}
  SectionSetFlags ${SEC01} $R1
  
  Call IsAviSynth26Installed
  Pop $R0
  StrCmp $R0 1 +2
    SectionSetFlags ${SEC02} ${SF_SELECTED}
    
  Call IsLAVFiltersInstalled
  Pop $R0
  StrCmp $R0 1 +5
    Call IsffdshowInstalled
    Pop $R0
    StrCmp $R0 1 +2
      SectionSetFlags ${SEC03} ${SF_SELECTED}

  IfFileExists $SYSDIR\mscomctl.ocx +2 +1
    SectionSetFlags ${SEC04} ${SF_SELECTED}

FunctionEnd

Function .onInstSuccess
  HideWindow
  ;MessageBox MB_YESNO '${PRODUCT_NAME} ${PRODUCT_VERSION} was installed. Do you want to run ${PRODUCT_NAME} now?'
  ;	 IDNO end
  ;  ExecShell open "$INSTDIR\${PRODUCT_NAME}.exe"
  ;end:
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_YESNO \
             'Do you want to remove ${PRODUCT_NAME} settings from Windows Registry (${PRODUCT_INST_ROOT_KEY}\${PRODUCT_INST_KEY})?' \
	 IDNO end
    DeleteRegKey "${PRODUCT_INST_ROOT_KEY}" "${PRODUCT_INST_KEY}"
  end:
  MessageBox MB_ICONINFORMATION|MB_OK "${PRODUCT_NAME} has been unistalled."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you really want to uninstall ${PRODUCT_NAME} and all its components?" IDYES +2
  Abort
FunctionEnd

Function IsAviSynthInstalled

 ; Returns on top of stack
 ; 0 (AviSynth is not installed)
 ; or
 ; 1 (AviSynth is installed)
 ;
 ; Usage:
 ;   Call IsAviSynthInstalled
 ;   Pop $R0
 ;   ; $R0 at this point is "1" or "0"

  Push $R0
  ClearErrors
  ReadRegStr $R0 HKLM "Software\AviSynth" ""
  IfErrors lbl_na
    StrCpy $R0 1
  Goto lbl_end
  lbl_na:
    StrCpy $R0 0
  lbl_end:
  Exch $R0
FunctionEnd

Function IsAviSynth26Installed

 ; Returns on top of stack
 ; 0 (AviSynth 2.6 is not installed)
 ; or
 ; 1 (AviSynth 2.6 is installed)
 ;
 ; Usage:
 ;   Call IsAviSynth26Installed
 ;   Pop $R0
 ;   ; $R0 at this point is "1" or "0"

  Push $R0
  ClearErrors
  ReadRegStr $R0 HKLM "Software\AviSynth" ""
  IfErrors lbl_na
    ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AviSynth" "DisplayName"
    StrCmp $R0 "AviSynth 2.6" +2
      Goto lbl_na
      StrCpy $R0 1
    Goto lbl_end
  lbl_na:
    StrCpy $R0 0
  lbl_end:
  Exch $R0
FunctionEnd

Function IsLAVFiltersInstalled

 ; Returns on top of stack
 ; 0 (LAVFilters is not installed)
 ; or
 ; 1 (LAVFilters is installed)
 ;
 ; Usage:
 ;   Call IsLAVFiltersInstalled
 ;   Pop $R0
 ;   ; $R0 at this point is "1" or "0"

  Push $R0
  ClearErrors
  ReadRegStr $R0 HKCR "CLSID\{EE30215D-164F-4A92-A4EB-9D4C13390F9F}\InprocServer32" ""
  IfErrors lbl_na
    StrCpy $R0 1
  Goto lbl_end
  lbl_na:
    StrCpy $R0 0
  lbl_end:
  Exch $R0
FunctionEnd

Function IsffdshowInstalled

 ; Returns on top of stack
 ; 0 (ffdshow is not installed)
 ; or
 ; 1 (ffdshow is installed)
 ;
 ; Usage:
 ;   Call IsffdshowInstalled
 ;   Pop $R0
 ;   ; $R0 at this point is "1" or "0"

  Push $R0
  ClearErrors
  ReadRegStr $R0 HKCR "CLSID\{04FE9017-F873-410E-871E-AB91661A4EF7}\InprocServer32" ""
  IfErrors lbl_na
    StrCpy $R0 1
  Goto lbl_end
  lbl_na:
    StrCpy $R0 0
  lbl_end:
  Exch $R0
FunctionEnd

Function FinishPre
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Settings' 'NumFields' '7'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'Type' 'Link'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'Top' '150'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'Bottom' '160'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'Left' '120'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'Right' '315'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'Text' \
  'Visit ImgBurn site to download the DVD burning app'
  WriteINIStr '$PLUGINSDIR\iospecial.ini' 'Field 7' 'State' \
  'http://www.imgburn.com'
FunctionEnd

Function FinishShow
  ReadIniStr $0 '$PLUGINSDIR\iospecial.ini' 'Field 7' 'HWND'
  SetCtlColors $0 '0x0000FF' '0xFFFFFF'
FunctionEnd
