!define APP_NAME      "SimpleCarApp"
!define APP_VERSION   "1.0.0"
!define APP_PUBLISHER "Студенческий проект"
!define APP_EXE       "SimpleCarApp.exe"
!define INSTALL_DIR   "$PROGRAMFILES\SimpleCarApp"
!define REG_KEY       "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"

Name "${APP_NAME} ${APP_VERSION}"
OutFile "SimpleCarAppSetup.exe"
InstallDir "${INSTALL_DIR}"
InstallDirRegKey HKLM "${REG_KEY}" "InstallLocation"
RequestExecutionLevel admin


Page directory
Page instfiles


UninstPage uninstConfirm
UninstPage instfiles

Section "MainSection" SEC01

  SetOutPath "$INSTDIR"


  File /r "files\*.*"


  CreateShortcut "$DESKTOP\SimpleCarApp.lnk" "$INSTDIR\${APP_EXE}"


  CreateDirectory "$SMPROGRAMS\${APP_NAME}"
  CreateShortcut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${APP_EXE}"
  CreateShortcut "$SMPROGRAMS\${APP_NAME}\Удалить.lnk"     "$INSTDIR\uninstall.exe"

  
  WriteRegStr   HKLM "${REG_KEY}" "DisplayName"      "${APP_NAME}"
  WriteRegStr   HKLM "${REG_KEY}" "DisplayVersion"   "${APP_VERSION}"
  WriteRegStr   HKLM "${REG_KEY}" "Publisher"        "${APP_PUBLISHER}"
  WriteRegStr   HKLM "${REG_KEY}" "InstallLocation"  "$INSTDIR"
  WriteRegStr   HKLM "${REG_KEY}" "UninstallString"  "$INSTDIR\uninstall.exe"

 
  WriteUninstaller "$INSTDIR\uninstall.exe"

 MessageBox MB_OK "Installation complete! Please ensure PostgreSQL is running."
SectionEnd


Section "Uninstall"


  RMDir /r "$INSTDIR"


  Delete "$DESKTOP\SimpleCarApp.lnk"
  Delete "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk"
  Delete "$SMPROGRAMS\${APP_NAME}\Удалить.lnk"
  RMDir  "$SMPROGRAMS\${APP_NAME}"


  DeleteRegKey HKLM "${REG_KEY}"

MessageBox MB_OK "Uninstall complete."

SectionEnd
