| 1 | Unicode true |
| 2 | !include "MUI2.nsh" |
| 3 | !include "nsDialogs.nsh" |
| 4 | !include "LogicLib.nsh" |
| 5 | !include "x64.nsh" |
| 6 | !include "FileFunc.nsh" |
| 7 | Name "Zipelo" |
| 8 | OutFile "Zipelo-0.2.1-windows-x64-setup.exe" |
| 9 | !define INSTALLROOT "$LOCALAPPDATA\Programs\Zipelo" |
| 10 | InstallDir "${INSTALLROOT}" |
| 11 | RequestExecutionLevel user |
| 12 | SetCompressor /SOLID lzma |
| 13 | SetOverwrite off |
| 14 | AllowSkipFiles off |
| 15 | ShowInstDetails show |
| 16 | !define MUI_ICON "zipelo.ico" |
| 17 | !define MUI_UNICON "zipelo.ico" |
| 18 | !define MUI_ABORTWARNING |
| 19 | !define MUI_CUSTOMFUNCTION_ABORT Rollback |
| 20 | !insertmacro MUI_PAGE_WELCOME |
| 21 | !insertmacro MUI_PAGE_INSTFILES |
| 22 | Page custom FinishCreate |
| 23 | UninstPage custom un.AssociationsCreate |
| 24 | !insertmacro MUI_UNPAGE_CONFIRM |
| 25 | !insertmacro MUI_UNPAGE_INSTFILES |
| 26 | !insertmacro MUI_LANGUAGE "Korean" |
| 27 | Var Dialog |
| 28 | Var ApplyButton |
| 29 | Var Mutex |
| 30 | Var RootOwned |
| 31 | Var ShortcutOwned |
| 32 | Var UninstallOwned |
| 33 | Var InstallComplete |
| 34 | Var Upgrading |
| 35 | Var StageDir |
| 36 | Var BackupBits |
| 37 | Var PublishedBits |
| 38 | Var RestoreFailed |
| 39 | Var OldVersion |
| 40 | Var VersionChanged |
| 41 | !define APPKEY "Software\Zipelo" |
| 42 | !define PROGKEY "Software\Classes\Zipelo.Archive" |
| 43 | !define UNKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Zipelo" |
| 44 | |
| 45 | ; 기존 앱을 먼저 치우고 새 앱은 마지막에 공개하여 버전 혼합 실행을 줄임. |
| 46 | !macro BackupFile NAME BIT |
| 47 | ClearErrors |
| 48 | Rename "$INSTDIR\${NAME}" "$StageDir\previous\${NAME}" |
| 49 | IfErrors failed |
| 50 | IntOp $BackupBits $BackupBits | ${BIT} |
| 51 | !macroend |
| 52 | |
| 53 | !macro PublishFile NAME BIT |
| 54 | ClearErrors |
| 55 | Rename "$StageDir\${NAME}" "$INSTDIR\${NAME}" |
| 56 | IfErrors failed |
| 57 | IntOp $PublishedBits $PublishedBits | ${BIT} |
| 58 | !macroend |
| 59 | |
| 60 | !macro RestoreFile NAME BIT |
| 61 | IntOp $0 $PublishedBits & ${BIT} |
| 62 | ${If} $0 != 0 |
| 63 | ClearErrors |
| 64 | Delete "$INSTDIR\${NAME}" |
| 65 | ${If} ${Errors} |
| 66 | StrCpy $RestoreFailed 1 |
| 67 | ${Else} |
| 68 | IntOp $PublishedBits $PublishedBits ^ ${BIT} |
| 69 | ${EndIf} |
| 70 | ${EndIf} |
| 71 | IntOp $0 $BackupBits & ${BIT} |
| 72 | ${If} $0 != 0 |
| 73 | ClearErrors |
| 74 | Rename "$StageDir\previous\${NAME}" "$INSTDIR\${NAME}" |
| 75 | ${If} ${Errors} |
| 76 | StrCpy $RestoreFailed 1 |
| 77 | ${Else} |
| 78 | IntOp $BackupBits $BackupBits ^ ${BIT} |
| 79 | ${EndIf} |
| 80 | ${EndIf} |
| 81 | !macroend |
| 82 | |
| 83 | !macro CleanupStageFile NAME |
| 84 | Delete "$StageDir\${NAME}" |
| 85 | ${If} $InstallComplete == 1 |
| 86 | Delete "$StageDir\previous\${NAME}" |
| 87 | ${EndIf} |
| 88 | !macroend |
| 89 | |
| 90 | !macro CheckInstalledFile NAME |
| 91 | System::Call 'kernel32::GetFileAttributesW(w "$INSTDIR\${NAME}") i.r0' |
| 92 | ${If} $0 == -1 |
| 93 | Goto failed |
| 94 | ${EndIf} |
| 95 | IntOp $0 $0 & 0x410 |
| 96 | ${If} $0 != 0 |
| 97 | Goto failed |
| 98 | ${EndIf} |
| 99 | !macroend |
| 100 | |
| 101 | Function .onInit |
| 102 | ${IfNot} ${RunningX64} |
| 103 | MessageBox MB_OK|MB_ICONSTOP "64비트 Windows가 필요합니다." |
| 104 | Abort |
| 105 | ${EndIf} |
| 106 | SetShellVarContext current |
| 107 | SetRegView 64 |
| 108 | System::Call 'kernel32::SetLastError(i 0)' |
| 109 | System::Call 'kernel32::CreateMutexW(p 0, i 0, w "Local\ZipeloSetup") p.r0 ?e' |
| 110 | Pop $1 |
| 111 | StrCpy $Mutex $0 |
| 112 | ${If} $0 == 0 |
| 113 | ${OrIf} $1 != 0 |
| 114 | MessageBox MB_OK "다른 설치나 제거를 마친 뒤 다시 실행하세요." |
| 115 | Abort |
| 116 | ${EndIf} |
| 117 | FunctionEnd |
| 118 | |
| 119 | Section "Zipelo" |
| 120 | ; /D로 바뀐 경로를 파일 쓰기 전에 고정하여 제거 경로와 일치시킴. |
| 121 | StrCpy $INSTDIR "${INSTALLROOT}" |
| 122 | ; 설치 표식과 제거 등록이 일치하는 기존 설치만 업데이트함. |
| 123 | IfFileExists "$INSTDIR" upgrade |
| 124 | Goto fresh |
| 125 | upgrade: |
| 126 | System::Call 'kernel32::GetFileAttributesW(w "$INSTDIR") i.r0' |
| 127 | IntOp $0 $0 & 0x410 |
| 128 | IntCmp $0 0x10 0 failed failed |
| 129 | ReadINIStr $0 "$INSTDIR\install.ini" "Zipelo" "Location" |
| 130 | StrCmp $0 $INSTDIR 0 failed |
| 131 | ReadRegStr $0 HKCU "${UNKEY}" "UninstallString" |
| 132 | StrCmp $0 '$\"$INSTDIR\Uninstall.exe$\"' 0 failed |
| 133 | !insertmacro CheckInstalledFile "Zipelo.exe" |
| 134 | !insertmacro CheckInstalledFile "zipelo-archive-worker.exe" |
| 135 | !insertmacro CheckInstalledFile "LICENSE" |
| 136 | !insertmacro CheckInstalledFile "THIRD-PARTY-LICENSES.txt" |
| 137 | !insertmacro CheckInstalledFile "BUILD-INFO.json" |
| 138 | !insertmacro CheckInstalledFile "Uninstall.exe" |
| 139 | !insertmacro CheckInstalledFile "install.ini" |
| 140 | ClearErrors |
| 141 | ReadRegStr $OldVersion HKCU "${UNKEY}" "DisplayVersion" |
| 142 | IfErrors failed |
| 143 | StrCpy $Upgrading 1 |
| 144 | Goto prepare |
| 145 | fresh: |
| 146 | System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${APPKEY}", i 0, i 0x20119, *p.r1) i.r0' |
| 147 | ${If} $0 == 0 |
| 148 | System::Call 'advapi32::RegCloseKey(p r1)' |
| 149 | Goto failed |
| 150 | ${ElseIf} $0 != 2 |
| 151 | Goto failed |
| 152 | ${EndIf} |
| 153 | System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${PROGKEY}", i 0, i 0x20119, *p.r1) i.r0' |
| 154 | ${If} $0 == 0 |
| 155 | System::Call 'advapi32::RegCloseKey(p r1)' |
| 156 | Goto failed |
| 157 | ${ElseIf} $0 != 2 |
| 158 | Goto failed |
| 159 | ${EndIf} |
| 160 | System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${UNKEY}", i 0, i 0x20119, *p.r1) i.r0' |
| 161 | ${If} $0 == 0 |
| 162 | System::Call 'advapi32::RegCloseKey(p r1)' |
| 163 | Goto failed |
| 164 | ${ElseIf} $0 != 2 |
| 165 | Goto failed |
| 166 | ${EndIf} |
| 167 | ; 공유 등록 값이 이미 있으면 형식과 관계없이 보존함. |
| 168 | System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "Software\RegisteredApplications", i 0, i 0x20119, *p.r1) i.r0' |
| 169 | ${If} $0 == 0 |
| 170 | System::Call 'advapi32::RegQueryValueExW(p r1, w "Zipelo", p 0, p 0, p 0, p 0) i.r2' |
| 171 | System::Call 'advapi32::RegCloseKey(p r1)' |
| 172 | ${If} $2 != 2 |
| 173 | Goto failed |
| 174 | ${EndIf} |
| 175 | ${ElseIf} $0 != 2 |
| 176 | Goto failed |
| 177 | ${EndIf} |
| 178 | IfFileExists "$SMPROGRAMS\Zipelo.lnk" failed |
| 179 | ClearErrors |
| 180 | CreateDirectory "$LOCALAPPDATA\Programs" |
| 181 | IfErrors failed |
| 182 | System::Call 'kernel32::CreateDirectoryW(w "$INSTDIR", p 0) i.r0' |
| 183 | IntCmp $0 0 failed |
| 184 | StrCpy $RootOwned 1 |
| 185 | prepare: |
| 186 | ; 같은 볼륨에 새 파일을 모두 준비한 뒤에만 기존 파일을 이동함. |
| 187 | ClearErrors |
| 188 | GetTempFileName $StageDir "$LOCALAPPDATA\Programs" |
| 189 | IfErrors failed |
| 190 | Delete "$StageDir" |
| 191 | System::Call 'kernel32::CreateDirectoryW(w "$StageDir", p 0) i.r0' |
| 192 | ${If} $0 == 0 |
| 193 | StrCpy $StageDir "" |
| 194 | Goto failed |
| 195 | ${EndIf} |
| 196 | SetOutPath "$StageDir" |
| 197 | ClearErrors |
| 198 | File "payload\Zipelo.exe" |
| 199 | File "payload\zipelo-archive-worker.exe" |
| 200 | File "payload\LICENSE" |
| 201 | File "payload\THIRD-PARTY-LICENSES.txt" |
| 202 | File "payload\BUILD-INFO.json" |
| 203 | IfErrors failed |
| 204 | WriteUninstaller "$StageDir\Uninstall.exe" |
| 205 | IfErrors failed |
| 206 | WriteINIStr "$StageDir\install.ini" "Zipelo" "Location" "$INSTDIR" |
| 207 | IfErrors failed |
| 208 | ${If} $Upgrading == 1 |
| 209 | ; 준비 후 취소하면 기존 설치와 연결은 전혀 바뀌지 않음. |
| 210 | MessageBox MB_OKCANCEL|MB_ICONINFORMATION "업데이트 준비가 끝났습니다. Zipelo와 압축 작업을 닫고 [확인]을 누르세요. [취소]를 누르면 기존 설치를 유지합니다." /SD IDOK IDCANCEL cancelled |
| 211 | CreateDirectory "$StageDir\previous" |
| 212 | IfErrors failed |
| 213 | !insertmacro BackupFile "Zipelo.exe" 1 |
| 214 | !insertmacro BackupFile "zipelo-archive-worker.exe" 2 |
| 215 | !insertmacro BackupFile "LICENSE" 4 |
| 216 | !insertmacro BackupFile "THIRD-PARTY-LICENSES.txt" 8 |
| 217 | !insertmacro BackupFile "BUILD-INFO.json" 16 |
| 218 | !insertmacro BackupFile "Uninstall.exe" 32 |
| 219 | !insertmacro BackupFile "install.ini" 64 |
| 220 | ${EndIf} |
| 221 | !insertmacro PublishFile "zipelo-archive-worker.exe" 2 |
| 222 | !insertmacro PublishFile "LICENSE" 4 |
| 223 | !insertmacro PublishFile "THIRD-PARTY-LICENSES.txt" 8 |
| 224 | !insertmacro PublishFile "BUILD-INFO.json" 16 |
| 225 | !insertmacro PublishFile "Uninstall.exe" 32 |
| 226 | !insertmacro PublishFile "install.ini" 64 |
| 227 | !insertmacro PublishFile "Zipelo.exe" 1 |
| 228 | ${If} $Upgrading == 1 |
| 229 | StrCpy $VersionChanged 1 |
| 230 | ClearErrors |
| 231 | WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "0.2.1" |
| 232 | IfErrors failed |
| 233 | Goto committed |
| 234 | ${EndIf} |
| 235 | StrCpy $ShortcutOwned 1 |
| 236 | CreateShortcut "$SMPROGRAMS\Zipelo.lnk" "$INSTDIR\Zipelo.exe" |
| 237 | IfErrors failed |
| 238 | StrCpy $UninstallOwned 1 |
| 239 | WriteRegStr HKCU "${UNKEY}" "DisplayName" "Zipelo" |
| 240 | WriteRegStr HKCU "${UNKEY}" "DisplayIcon" '$\"$INSTDIR\Zipelo.exe$\",0' |
| 241 | WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "0.2.1" |
| 242 | WriteRegStr HKCU "${UNKEY}" "UninstallString" '$\"$INSTDIR\Uninstall.exe$\"' |
| 243 | IfErrors failed |
| 244 | committed: |
| 245 | StrCpy $InstallComplete 1 |
| 246 | Call CleanupStage |
| 247 | Goto done |
| 248 | cancelled: |
| 249 | Call Rollback |
| 250 | SetErrorLevel 2 |
| 251 | Abort "업데이트를 취소했습니다" |
| 252 | failed: |
| 253 | Call Rollback |
| 254 | SetErrorLevel 1 |
| 255 | MessageBox MB_OK|MB_ICONSTOP "설치를 완료하지 못했습니다. Zipelo와 압축 작업을 닫고 여유 공간과 쓰기 권한을 확인하세요. 복원하지 못한 파일이 있으면 상세 보기의 백업 경로를 보존하고 다시 설치하지 마세요." /SD IDOK |
| 256 | Abort |
| 257 | done: |
| 258 | SectionEnd |
| 259 | |
| 260 | Function Rollback |
| 261 | ${If} $InstallComplete == 1 |
| 262 | Return |
| 263 | ${EndIf} |
| 264 | ${If} $Upgrading == 1 |
| 265 | SetOutPath "$TEMP" |
| 266 | !insertmacro RestoreFile "zipelo-archive-worker.exe" 2 |
| 267 | !insertmacro RestoreFile "LICENSE" 4 |
| 268 | !insertmacro RestoreFile "THIRD-PARTY-LICENSES.txt" 8 |
| 269 | !insertmacro RestoreFile "BUILD-INFO.json" 16 |
| 270 | !insertmacro RestoreFile "Uninstall.exe" 32 |
| 271 | !insertmacro RestoreFile "install.ini" 64 |
| 272 | !insertmacro RestoreFile "Zipelo.exe" 1 |
| 273 | ${If} $VersionChanged == 1 |
| 274 | ClearErrors |
| 275 | WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "$OldVersion" |
| 276 | ${If} ${Errors} |
| 277 | StrCpy $RestoreFailed 1 |
| 278 | ${Else} |
| 279 | StrCpy $VersionChanged 0 |
| 280 | ${EndIf} |
| 281 | ${EndIf} |
| 282 | ${If} $RestoreFailed == 1 |
| 283 | DetailPrint "복원 실패: 백업 폴더 $StageDir\previous 를 보존하세요." |
| 284 | ${EndIf} |
| 285 | Call CleanupStage |
| 286 | Return |
| 287 | ${EndIf} |
| 288 | Call CleanupStage |
| 289 | ${If} $RootOwned != 1 |
| 290 | Return |
| 291 | ${EndIf} |
| 292 | SetOutPath "$TEMP" |
| 293 | ${If} $ShortcutOwned == 1 |
| 294 | Delete "$SMPROGRAMS\Zipelo.lnk" |
| 295 | ${EndIf} |
| 296 | ${If} $UninstallOwned == 1 |
| 297 | DeleteRegValue HKCU "${UNKEY}" "DisplayIcon" |
| 298 | DeleteRegValue HKCU "${UNKEY}" "DisplayName" |
| 299 | DeleteRegValue HKCU "${UNKEY}" "DisplayVersion" |
| 300 | DeleteRegValue HKCU "${UNKEY}" "UninstallString" |
| 301 | DeleteRegKey /ifempty HKCU "${UNKEY}" |
| 302 | ${EndIf} |
| 303 | Delete "$INSTDIR\Zipelo.exe" |
| 304 | Delete "$INSTDIR\zipelo-archive-worker.exe" |
| 305 | Delete "$INSTDIR\LICENSE" |
| 306 | Delete "$INSTDIR\THIRD-PARTY-LICENSES.txt" |
| 307 | Delete "$INSTDIR\BUILD-INFO.json" |
| 308 | Delete "$INSTDIR\install.ini" |
| 309 | Delete "$INSTDIR\Uninstall.exe" |
| 310 | RMDir "$INSTDIR" |
| 311 | StrCpy $RootOwned 0 |
| 312 | FunctionEnd |
| 313 | |
| 314 | Function CleanupStage |
| 315 | ${If} $StageDir == "" |
| 316 | Return |
| 317 | ${EndIf} |
| 318 | SetOutPath "$TEMP" |
| 319 | !insertmacro CleanupStageFile "Zipelo.exe" |
| 320 | !insertmacro CleanupStageFile "zipelo-archive-worker.exe" |
| 321 | !insertmacro CleanupStageFile "LICENSE" |
| 322 | !insertmacro CleanupStageFile "THIRD-PARTY-LICENSES.txt" |
| 323 | !insertmacro CleanupStageFile "BUILD-INFO.json" |
| 324 | !insertmacro CleanupStageFile "Uninstall.exe" |
| 325 | !insertmacro CleanupStageFile "install.ini" |
| 326 | RMDir "$StageDir\previous" |
| 327 | ClearErrors |
| 328 | RMDir "$StageDir" |
| 329 | ${If} ${Errors} |
| 330 | DetailPrint "임시 파일 또는 복원 백업이 남아 있음: $StageDir" |
| 331 | ${Else} |
| 332 | StrCpy $StageDir "" |
| 333 | ${EndIf} |
| 334 | FunctionEnd |
| 335 | |
| 336 | Function .onInstFailed |
| 337 | Call Rollback |
| 338 | SetErrorLevel 1 |
| 339 | FunctionEnd |
| 340 | |
| 341 | Function FinishCreate |
| 342 | GetDlgItem $0 $HWNDPARENT 1 |
| 343 | SendMessage $0 ${WM_SETTEXT} 0 "STR:마침" |
| 344 | GetDlgItem $0 $HWNDPARENT 3 |
| 345 | EnableWindow $0 0 |
| 346 | nsDialogs::Create 1018 |
| 347 | Pop $Dialog |
| 348 | ${If} $Dialog == error |
| 349 | Abort |
| 350 | ${EndIf} |
| 351 | ${NSD_CreateLabel} 0 0 100% 28u "Zipelo 설치가 끝났습니다." |
| 352 | Pop $0 |
| 353 | ${NSD_CreateLabel} 0 32u 100% 40u "[적용]을 누르면 Zipelo를 연결 프로그램으로 등록하고 Windows 기본 앱 설정을 엽니다. 기본 앱은 설정에서 직접 선택하세요." |
| 354 | Pop $0 |
| 355 | ${NSD_CreateButton} 0 84u 100% 26u "적용" |
| 356 | Pop $ApplyButton |
| 357 | ${NSD_OnClick} $ApplyButton ApplyAssociations |
| 358 | nsDialogs::Show |
| 359 | FunctionEnd |
| 360 | |
| 361 | Function ApplyAssociations |
| 362 | Pop $0 |
| 363 | ClearErrors |
| 364 | WriteRegStr HKCU "${PROGKEY}" "" "Zipelo 압축파일" |
| 365 | WriteRegStr HKCU "${PROGKEY}\DefaultIcon" "" '$\"$INSTDIR\Zipelo.exe$\",0' |
| 366 | WriteRegStr HKCU "${PROGKEY}\shell\open\command" "" '$\"$INSTDIR\Zipelo.exe$\" $\"%1$\"' |
| 367 | WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationName" "Zipelo" |
| 368 | WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationDescription" "압축파일 열기와 풀기" |
| 369 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip" "Zipelo.Archive" |
| 370 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".7z" "Zipelo.Archive" |
| 371 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar" "Zipelo.Archive" |
| 372 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz" "Zipelo.Archive" |
| 373 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz" "Zipelo.Archive" |
| 374 | WriteRegStr HKCU "Software\RegisteredApplications" "Zipelo" "${APPKEY}\Capabilities" |
| 375 | IfErrors register_failed |
| 376 | System::Call 'shell32::SHChangeNotify(i 0x8000000, i 0, p 0, p 0)' |
| 377 | ExecShell "open" "ms-settings:defaultapps" |
| 378 | IfErrors settings_failed |
| 379 | Return |
| 380 | register_failed: |
| 381 | MessageBox MB_OK|MB_ICONSTOP "연결 프로그램을 등록하지 못했습니다. 쓰기 권한을 확인한 뒤 다시 적용하세요." |
| 382 | Return |
| 383 | settings_failed: |
| 384 | MessageBox MB_OK "Windows 설정을 열지 못했습니다. 설정에서 앱 > 기본 앱을 직접 열어주세요." |
| 385 | FunctionEnd |
| 386 | |
| 387 | ; 현재 값이 설치 시 기록한 값과 같은 경우에만 지움. |
| 388 | !macro RemoveOwnedValue KEY NAME EXPECTED |
| 389 | ReadRegStr $0 HKCU "${KEY}" "${NAME}" |
| 390 | ${If} $0 S== "${EXPECTED}" |
| 391 | DeleteRegValue HKCU "${KEY}" "${NAME}" |
| 392 | ${EndIf} |
| 393 | !macroend |
| 394 | |
| 395 | Function un.AssociationsCreate |
| 396 | nsDialogs::Create 1018 |
| 397 | Pop $Dialog |
| 398 | ${If} $Dialog == error |
| 399 | Abort |
| 400 | ${EndIf} |
| 401 | ${NSD_CreateLabel} 0 0 100% 62u "Zipelo를 기본 앱으로 사용했다면 제거 전에 다른 앱을 선택하세요. [기본 앱 설정 열기]에서 .zip, .7z, .tar, .gz, .tgz를 검색해 사용할 앱을 고를 수 있습니다. 다른 앱이 없으면 먼저 설치하세요." |
| 402 | Pop $0 |
| 403 | ${NSD_CreateLabel} 0 66u 100% 38u "직접 고른 기본 앱은 자동으로 바꾸지 않습니다. 제거 후 파일이 열리지 않으면 파일을 오른쪽 클릭하고 [연결 프로그램]에서 다른 앱을 선택하세요." |
| 404 | Pop $0 |
| 405 | ${NSD_CreateButton} 0 112u 100% 24u "기본 앱 설정 열기" |
| 406 | Pop $ApplyButton |
| 407 | ${NSD_OnClick} $ApplyButton un.OpenDefaultApps |
| 408 | nsDialogs::Show |
| 409 | FunctionEnd |
| 410 | |
| 411 | Function un.OpenDefaultApps |
| 412 | Pop $0 |
| 413 | ClearErrors |
| 414 | ExecShell "open" "ms-settings:defaultapps" |
| 415 | ${If} ${Errors} |
| 416 | MessageBox MB_OK "Windows 설정을 열지 못했습니다. 설정 > 앱 > 기본 앱에서 확장자를 검색해 다른 앱을 선택하세요." |
| 417 | ${EndIf} |
| 418 | FunctionEnd |
| 419 | |
| 420 | Function un.onInit |
| 421 | SetShellVarContext current |
| 422 | SetRegView 64 |
| 423 | System::Call 'kernel32::SetLastError(i 0)' |
| 424 | System::Call 'kernel32::CreateMutexW(p 0, i 0, w "Local\ZipeloSetup") p.r0 ?e' |
| 425 | Pop $1 |
| 426 | StrCpy $Mutex $0 |
| 427 | ${If} $0 == 0 |
| 428 | ${OrIf} $1 != 0 |
| 429 | Abort |
| 430 | ${EndIf} |
| 431 | StrCmp $INSTDIR "${INSTALLROOT}" 0 invalid |
| 432 | ReadINIStr $0 "$INSTDIR\install.ini" "Zipelo" "Location" |
| 433 | StrCmp $0 $INSTDIR 0 invalid |
| 434 | Return |
| 435 | invalid: |
| 436 | MessageBox MB_OK|MB_ICONSTOP "설치 위치를 확인하지 못했습니다. 파일을 삭제하지 않습니다." |
| 437 | Abort |
| 438 | FunctionEnd |
| 439 | |
| 440 | Section "Uninstall" |
| 441 | SetOutPath "$TEMP" |
| 442 | ClearErrors |
| 443 | Delete "$INSTDIR\Zipelo.exe" |
| 444 | Delete "$INSTDIR\zipelo-archive-worker.exe" |
| 445 | IfErrors uninstall_failed |
| 446 | Delete "$INSTDIR\LICENSE" |
| 447 | Delete "$INSTDIR\THIRD-PARTY-LICENSES.txt" |
| 448 | Delete "$INSTDIR\BUILD-INFO.json" |
| 449 | Delete "$SMPROGRAMS\Zipelo.lnk" |
| 450 | IfErrors uninstall_failed |
| 451 | ; 자신이 등록한 값만 제거하고 다른 파일과 키를 보존함. |
| 452 | ReadRegStr $0 HKCU "Software\RegisteredApplications" "Zipelo" |
| 453 | ${If} $0 == "${APPKEY}\Capabilities" |
| 454 | DeleteRegValue HKCU "Software\RegisteredApplications" "Zipelo" |
| 455 | ${EndIf} |
| 456 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".zip" "Zipelo.Archive" |
| 457 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".7z" "Zipelo.Archive" |
| 458 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".tar" "Zipelo.Archive" |
| 459 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".gz" "Zipelo.Archive" |
| 460 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".tgz" "Zipelo.Archive" |
| 461 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities" "ApplicationName" "Zipelo" |
| 462 | !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities" "ApplicationDescription" "압축파일 열기와 풀기" |
| 463 | DeleteRegKey /ifempty HKCU "${APPKEY}\Capabilities\FileAssociations" |
| 464 | DeleteRegKey /ifempty HKCU "${APPKEY}\Capabilities" |
| 465 | DeleteRegKey /ifempty HKCU "${APPKEY}" |
| 466 | !insertmacro RemoveOwnedValue "${PROGKEY}\shell\open\command" "" '$\"$INSTDIR\Zipelo.exe$\" $\"%1$\"' |
| 467 | !insertmacro RemoveOwnedValue "${PROGKEY}\DefaultIcon" "" '$\"$INSTDIR\Zipelo.exe$\",0' |
| 468 | DeleteRegKey /ifempty HKCU "${PROGKEY}\DefaultIcon" |
| 469 | !insertmacro RemoveOwnedValue "${PROGKEY}" "" "Zipelo 압축파일" |
| 470 | DeleteRegKey /ifempty HKCU "${PROGKEY}\shell\open\command" |
| 471 | DeleteRegKey /ifempty HKCU "${PROGKEY}\shell\open" |
| 472 | DeleteRegKey /ifempty HKCU "${PROGKEY}\shell" |
| 473 | DeleteRegKey /ifempty HKCU "${PROGKEY}" |
| 474 | DeleteRegValue HKCU "${UNKEY}" "DisplayIcon" |
| 475 | DeleteRegValue HKCU "${UNKEY}" "DisplayName" |
| 476 | DeleteRegValue HKCU "${UNKEY}" "DisplayVersion" |
| 477 | DeleteRegValue HKCU "${UNKEY}" "UninstallString" |
| 478 | DeleteRegKey /ifempty HKCU "${UNKEY}" |
| 479 | Delete "$INSTDIR\install.ini" |
| 480 | Delete "$INSTDIR\Uninstall.exe" |
| 481 | RMDir "$INSTDIR" |
| 482 | System::Call 'shell32::SHChangeNotify(i 0x8000000, i 0, p 0, p 0)' |
| 483 | Goto un_done |
| 484 | uninstall_failed: |
| 485 | SetErrorLevel 1 |
| 486 | MessageBox MB_OK|MB_ICONSTOP "Zipelo와 작업자를 닫은 뒤 제거 프로그램을 다시 실행하세요." |
| 487 | Abort |
| 488 | un_done: |
| 489 | SectionEnd |