관리 메뉴

ㄴrㅎnㅂrㄹrㄱi

NsisInstaller 본문

프로그래밍/NSIS

NsisInstaller

님투 2007. 11. 3. 21:19
반응형

Introduction

  • nsis 에 대해 적는다.
  • nsis 는 인스톨러다... 너무 맘에 든다... 쉬우니깐... 간단하고... 쥑인다... modern ui 를 이용하면 세련된 설치 마법사를 만들 수 있다.

Detailed Description

Basic

  • 다운 받아서 설치한다.. (reference 참고)
  • *.nsi 를 만든다.
    • 문서가 너무 잘나와 있다. 문서 보고 예제 보면 뚝딱... 특히 nsis 를 install 하는 스크립트가 짱이다.
      • 기본적인 것은 다음과 같다.
        • 첫째, installer attributes 를 잘 설정한다.
        • 둘째, pages 를 잘 설정한다.
        • 셋째, sections 를 잘 설정한다.
  • 만들어진 *.nsi 파일을 우클릭후 context menu 에서 compile 해버린다. 에러 참고 하면서 수정한다.
  • 만들어진 *.exe 를 배포한다. 끝.

ex 1 : simple activex

Name "RBT Generator Control"
Caption "RBT Generator 1.0.0.14 Setup"

OutFile "rbtctrl.exe"

InstallDir $SYSDIR

Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

; 기본 인스톨 폴더
;INSTDIR $SYSDIR

Section ""
        SetOutPath $INSTDIR
        SetOverwrite on

        File cbrt.dll
        RegDLL $SYSDIR\cbrt.dll

        ; Write the uninstall keys for Windows
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "DisplayName" "RBT Generator Control"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "UninstallString" '"$INSTDIR\crbt_uninst.exe"'
        WriteRegDWORD   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "NoModify" 1
        WriteRegDWORD   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "NoRepair" 1
        WriteUninstaller "crbt_uninst.exe"
SectionEnd

Section Uninstall
        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen"

        UnRegDLL $INSTDIR\cbrt.dll
        Delete $INSTDIR\cbrt.dll
SectionEnd

ex2 : simple application

  • 필요한 regstry 값을 넣는다.
  • 특정 확장자에 대해 application 이 실행되게 한다.
  • 시작메뉴,바탕화면 바로 가기 등등을 생성한다.
  • 위 사항에 대한 uninstaller 를 생성한다.
  • modern ui 를 아직 적용하지는 않았다.

; Melon Setup script
;

!define VER_MAJOR 1
!define VER_MINOR 0
!define VER_REVISION 0
!define VER_BUILD 1

!define VER_FILE "20"
!define VER_DISPLAY "1.0"

;--------------------------------
;Header Files
;--------------------------------

;!include "MUI.nsh"
;!include "Sections.nsh"

;----------------------------------------
;Configuration
;----------------------------------------
        OutFile "MelonSetup.exe"
        SetCompressor lzma

        InstallDir "$PROGRAMFILES\Melon Player"
        InstallDirRegKey HKCU Software\MelonPlayer ""

        Name "Melon Player"
        Caption "Melon ${VER_DISPLAY} Setup"

        ShowInstDetails show    
        ShowUninstDetails show
        XPStyle on

;----------------------------------------
;Pages
;----------------------------------------
        Page components
        Page directory
        Page instfiles

        UninstPage uninstConfirm
        UninstPage instfiles

;--------------------------------
; Declaration of user variables (Var command), allowed charaters for variables names : [a-z][A-Z][0-9] and '_'
  Var "Info"

;--------------------------------
; Installer

Section "Melon Player Core Files (required)" secCore

        SetDetailsPrint textonly
        DetailPrint "Installing Melon Player Core Files..."
        SetDetailsPrint listonly

        sectionIn RO
        SetOutPath $INSTDIR
        RMDIR /r "$SMPROGRAMS\Melon Player"
        
        SetOverwrite on

        File AutoUp.exe
        File Melon.exe
        File CWLib.dll
        File IKMMSClt.dll
        File Melon_Album.dll
        File Melon_Comm.dll
        File Melon_Common.dll
        File Melon_img.dll
        File Melon_List.dll
        File Melon_Player.dll
        File MelonSync.dll
        File PCSync.dll
        File sktdrm.dll
        File SQLITE.dll
        File WACDMP3.dll
        File WACDOGG.dll
        File WACDWAV.dll
        File WACDWMA.dll
        File WACORE.dll

        File /r skin
        File /r conf

        ; required registry item
        ReadRegstr $R0 HKCU "Software\Melon\" "InstallPath"
        StrCmp $R0 "" 0 +2
                DeleteRegKey HKCU "Software\Melon\" 

        WriteRegStr HKCU "Software\Melon\" "InstallPath" "$INSTDIR\Melon.exe"

        ; default open command
        ReadRegStr $R0 HKCR ".dcf" ""
        StrCmp $R0 "MelonFile" 0 +2
                DeleteRegKey HKCR "MelonFile"

        WriteRegStr HKCR ".dcf" "" "Melon.Media"
        WriteRegStr HKCR "Melon.Media" "" "Melon Media File"
        WriteRegStr HKCR "Melon.Media\DefaultIcon" "" "$INSTDIR\Melon.exe,1"
        ReadRegStr $R0 HKCR "Melon.Media\shell\open\command" ""
        StrCmp $R0 "" 0 no_dcfopen
                WriteRegStr HKCR "Melon.Media\shell" "" "open"
                WriteRegStr HKCR "Melon.Media\shell\open\command" "" 'notepad.exe "%1"'
        no_dcfopen:
        WriteRegStr HKCR "Melon.Media\shell" "" "open"
        WriteRegStr HKCR "Melon.Media\shell\open\command" "" '"$INSTDIR\Melon.exe" "%1"'

        ; Write the uninstall keys for Windows
        ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "DisplayName" "RBT Generator Control"
        ;WriteRegDWORD  HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "NoRepair" 1
        ;WriteUninstaller "crbt_uninst.exe"

        ;CreateDirectory $INSTDIR
        WriteUninstaller "$INSTDIR\Uninst.exe"
    
SectionEnd

;--------------------------------
; Optional section (can be disabled by the user)

Section "Start Menu and Desktop Shortcuts" secShortcuts

        SetDetailsPrint textonly
        DetailPrint "Installing Start Menu and Desktop Shortcuts..."
        SetDetailsPrint listonly

        SetOutPath $INSTDIR

        CreateDirectory "$SMPROGRAMS\Melon Player"
        CreateShortCut "$SMPROGRAMS\Melon Player\Uninstall.lnk" "$INSTDIR\Uninst.exe" "" "$INSTDIR\Uninst.exe" 0
        CreateShortCut "$SMPROGRAMS\Melon Player\Melon Player.lnk" "$INSTDIR\Melon.exe" "" "$INSTDIR\Melon.exe" 0
        ;WriteINIStr "$SMPROGRAMS\Melon Player\Melon Site.url" "InternetShortcut" "URL" "http://www.melon.com/"
 
        
        CreateShortCut "$DESKTOP\Melon Player.lnk" "$INSTDIR\Melon.exe"

  
SectionEnd

Section -post

        SetDetailsPrint textonly
        DetailPrint "Creating Registry Keys..."
        SetDetailsPrint listonly

        SetOutPath $INSTDIR

        WriteRegStr HKCU "Software\Melon" "" $INSTDIR
        WriteRegDword HKCU "Software\Melon" "VersionMajor" "${VER_MAJOR}"
        WriteRegDword HKCU "Software\Melon" "VersionMinor" "${VER_MINOR}"
        WriteRegDword HKCU "Software\Melon" "VersionRevision" "${VER_REVISION}"
        WriteRegDword HKCU "Software\Melon" "VersionBuild" "${VER_BUILD}"

        WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "UninstallString" '"$INSTDIR\Uninst.exe"'
        WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "InstallLocation" "$INSTDIR"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "DisplayName" "Melon Player"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "DisplayIcon" "$INSTDIR\Melon.exe,0"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "DisplayVersion" "${VER_DISPLAY}"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "VersionMajor" "${VER_MAJOR}"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "VersionMinor" "${VER_MINOR}.${VER_REVISION}"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "URLInfoAbout" "http://www.melon.com/"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "NoModify" "1"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "NoRepair" "1"

SectionEnd

;--------------------------------
; Uninstaller

Section "Uninstall"
        SetDetailsPrint textonly
        DetailPrint "Uninstalling Melon Player Shell Extensions..."
        SetDetailsPrint listonly

        IfFileExists $INSTDIR\Melon.exe melon_installed
                MessageBox MB_YESNO "It does not appear that Melon is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES melon_installed
                Abort "Uninstall aborted by user"
        melon_installed:

        StrCpy $Info "Melon Player uninstalled successfully."

        SetDetailsPrint textonly
        DetailPrint "Deleting Registry Keys..."
        SetDetailsPrint listonly

        ReadRegStr $R0 HKCR ".dcf" ""
        StrCmp $R0 "Melon.Media" 0 +2
                DeleteRegKey HKCR ".dcf"

        DeleteRegKey HKCR "Melon.Media"

        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon"
        DeleteRegKey HKCU "Software\Melon"

        SetDetailsPrint textonly
        DetailPrint "Deleting Files..."
        SetDetailsPrint listonly

        ; Remove directories used
        RMDir /r "$SMPROGRAMS\Melon Player"
        RmDir /r $INSTDIR
        Delete "$DESKTOP\Melon Player.lnk"

        SetDetailsPrint both

SectionEnd

Function un.OnUninstSuccess

        HideWindow
        MessageBox MB_OK "$Info"
     
FunctionEnd


ex3 modern UI simple app

  • modern ui 를 적용했다... 그래도 정리할 것은 남아있다.

; Melon Setup script
;

!define VER_MAJOR 1
!define VER_MINOR 0
!define VER_REVISION 0
!define VER_BUILD 1

!define VER_FILE "20"
!define VER_DISPLAY "1.0"

!define PRODUCT_NAME "Melon Player"

;--------------------------------
;Header Files
;--------------------------------

!include "MUI.nsh"
;!include "Sections.nsh"

;--------------------------------
; Declaration of user variables (Var command), allowed charaters for variables names : [a-z][A-Z][0-9] and '_'

        Var "Info"
        Var STARTMENU_FOLDER
        Var MUI_TEMP
  

;----------------------------------------
;Configuration
;----------------------------------------
        OutFile "MelonSetup.exe"
        SetCompressor lzma

        InstallDir "$PROGRAMFILES\Melon Player"
        InstallDirRegKey HKCU Software\MelonPlayer ""

        Name "Melon Player"
        Caption "Melon ${VER_DISPLAY} Setup"

        ShowInstDetails show    
        ShowUninstDetails show
        XPStyle on
        BrandingText "Copyright ⓒ 2004 SKT Corp. All Rights Reserved."


;----------------------------------------
;Pages
;----------------------------------------
        ;Page components
        ;Page directory
        ;Page instfiles

        ;UninstPage uninstConfirm
        ;UninstPage instfiles

        ;--------------------------------
;Modern UI Configuration

        !define MUI_ABORTWARNING
        
        !define MUI_FONT_HEADER "굴림"
        !define MUI_FONTSIZE_HEADER "9"
        !define MUI_FONTSTYLE_HEADER "700"
        !define MUI_FONT_TITLE "굴림"
        !define MUI_FONTSIZE_TITLE "9"
        !define MUI_FONTSTYLE_TITLE "700"
        
;--------------------------------
;Pages

        !insertmacro MUI_PAGE_WELCOME 
        !insertmacro MUI_PAGE_LICENSE "License.txt"
        !insertmacro MUI_PAGE_COMPONENTS
        !insertmacro MUI_PAGE_DIRECTORY

        ;Start Menu Folder Page Configuration
        !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
        !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Melon" 
        !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Melon"
        !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Melon Player"

        !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER

        !insertmacro MUI_PAGE_INSTFILES

        !define MUI_FINISHPAGE_RUN "$INSTDIR\Melon.exe"
        ;!define MUI_FINISHPAGE_NOREBOOTSUPPORT
        !insertmacro MUI_PAGE_FINISH


        !insertmacro MUI_UNPAGE_CONFIRM
        !insertmacro MUI_UNPAGE_INSTFILES
        
;Language
        !insertmacro MUI_LANGUAGE "Korean"



;--------------------------------
; Installer

Section "Melon Player Core Files (required)" SecCore

        SetDetailsPrint textonly
        DetailPrint "Installing Melon Player Core Files..."
        SetDetailsPrint listonly

        sectionIn RO
        SetOutPath $INSTDIR
        RMDIR /r "$SMPROGRAMS\Melon Player"
        
        SetOverwrite on

        File ..\bin\Release\UpGradeMelon.exe
        File ..\bin\Release\Melon.exe
        File ..\bin\Release\CWLib.dll
        File ..\bin\Release\IKMMSClt.dll
        File ..\bin\Release\Melon_Album.dll
        File ..\bin\Release\Melon_Comm.dll
        File ..\bin\Release\Melon_Common.dll
        File ..\bin\Release\Melon_img.dll
        File ..\bin\Release\Melon_List.dll
        File ..\bin\Release\Melon_Player.dll
        File ..\bin\Release\MelonSync.dll
        File ..\bin\Release\PCSync.dll
        File ..\bin\Release\sktdrm.dll
        File ..\bin\Release\SQLITE.dll
        File ..\bin\Release\WACDMP3.dll
        File ..\bin\Release\WACDOGG.dll
        File ..\bin\Release\WACDWAV.dll
        File ..\bin\Release\WACDWMA.dll
        File ..\bin\Release\WACORE.dll
        File ..\bin\Release\sktauth.dll

        ;File /r skin
        ;File /r conf
        ;File /r plugin

        CreateDirectory "$INSTDIR\skin"
        SetOutPath "$INSTDIR\skin"
        File ..\bin\Release\skin\*.*

        CreateDirectory "$INSTDIR\conf"
        SetOutPath "$INSTDIR\conf"
        File ..\bin\Release\conf\*.*

        CreateDirectory "$INSTDIR\plugin"
        SetOutPath "$INSTDIR\plugin"
        File ..\bin\Release\plugin\*.*

        CreateDirectory "$INSTDIR\download"
        SetOutPath "$INSTDIR"

        ; required registry item
        ReadRegstr $R0 HKCU "Software\Melon\" "InstallPath"

        StrCmp $R0 "" 0 +2
                DeleteRegKey HKCU "Software\Melon\" 

        WriteRegStr HKCU "Software\Melon\" "InstallPath" "$INSTDIR\Melon.exe"

        ;ReadRegstr $R0 HKCU "Software\Melon\" "DownLoadFolder"
        ;StrCmp $R0 "" 0 +2
        ;       DeleteRegKey HKCU "Software\Melon\DownLoadFolder" 

        WriteRegStr HKCU "Software\Melon\" "DownLoadFolder" "$INSTDIR\download"

        ; default open command
        ReadRegStr $R0 HKCR ".dcf" ""
        StrCmp $R0 "MelonFile" 0 +2
                DeleteRegKey HKCR "MelonFile"

        WriteRegStr HKCR ".dcf" "" "Melon.Media"
        WriteRegStr HKCR "Melon.Media" "" "Melon Media File"
        WriteRegStr HKCR "Melon.Media\DefaultIcon" "" "$INSTDIR\Melon.exe,0"
        ReadRegStr $R0 HKCR "Melon.Media\shell\open\command" ""
        StrCmp $R0 "" 0 no_dcfopen
                WriteRegStr HKCR "Melon.Media\shell" "" "open"
                WriteRegStr HKCR "Melon.Media\shell\open\command" "" 'notepad.exe "%1"'
        no_dcfopen:
        WriteRegStr HKCR "Melon.Media\shell" "" "open"
        WriteRegStr HKCR "Melon.Media\shell\open\command" "" '"$INSTDIR\Melon.exe" "%1"'

        ; Write the uninstall keys for Windows
        ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "DisplayName" "RBT Generator Control"
        ;WriteRegDWORD  HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RBTGen" "NoRepair" 1
        ;WriteUninstaller "crbt_uninst.exe"

        ;CreateDirectory $INSTDIR
        WriteUninstaller "$INSTDIR\Uninst.exe"
    
SectionEnd

;--------------------------------
; Optional section (can be disabled by the user)

Section "Start Menu and Desktop Shortcuts" SecShortcuts

        SetDetailsPrint textonly
        DetailPrint "Installing Start Menu and Desktop Shortcuts..."
        SetDetailsPrint listonly

        SetOutPath $INSTDIR
        
        !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
        CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninst.exe" "" "$INSTDIR\Uninst.exe" 0
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Melon Player.lnk" "$INSTDIR\Melon.exe" "" "$INSTDIR\Melon.exe" 0
        CreateShortCut "$DESKTOP\Melon Player.lnk" "$INSTDIR\Melon.exe"

        ;CreateDirectory "$SMPROGRAMS\Melon Player"
        ;CreateShortCut "$SMPROGRAMS\Melon Player\Uninstall.lnk" "$INSTDIR\Uninst.exe" "" "$INSTDIR\Uninst.exe" 0
        ;CreateShortCut "$SMPROGRAMS\Melon Player\Melon Player.lnk" "$INSTDIR\Melon.exe" "" "$INSTDIR\Melon.exe" 0
        ;WriteINIStr "$SMPROGRAMS\Melon Player\Melon Site.url" "InternetShortcut" "URL" "http://www.melon.com/"
        ;CreateShortCut "$DESKTOP\Melon Player.lnk" "$INSTDIR\Melon.exe"

        !insertmacro MUI_STARTMENU_WRITE_END
        

  
SectionEnd

Section -post

        SetDetailsPrint textonly
        DetailPrint "Creating Registry Keys..."
        SetDetailsPrint listonly

        SetOutPath $INSTDIR

        WriteRegStr HKCU "Software\Melon" "" $INSTDIR
        WriteRegDword HKCU "Software\Melon" "VersionMajor" "${VER_MAJOR}"
        WriteRegDword HKCU "Software\Melon" "VersionMinor" "${VER_MINOR}"
        WriteRegDword HKCU "Software\Melon" "VersionRevision" "${VER_REVISION}"
        WriteRegDword HKCU "Software\Melon" "VersionBuild" "${VER_BUILD}"

        WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "UninstallString" '"$INSTDIR\Uninst.exe"'
        WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "InstallLocation" "$INSTDIR"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "DisplayName" "Melon Player"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "DisplayIcon" "$INSTDIR\Melon.exe,0"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "DisplayVersion" "${VER_DISPLAY}"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "VersionMajor" "${VER_MAJOR}"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "VersionMinor" "${VER_MINOR}.${VER_REVISION}"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "URLInfoAbout" "http://www.melon.com/"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "NoModify" "1"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon" "NoRepair" "1"

        ; prompt user, and if they select no, go to NoWinamp
        ;MessageBox MB_YESNO|MB_ICONQUESTION \
        ;       "Melon Player 가 설치되었습니다. Melon Player 를 실행하시겠습니가?" \
        ;       IDNO NoMelonPlayer
        ;       Exec '"$INSTDIR\Melon.exe"'
        ;       Quit
        ;NoMelonPlayer:

SectionEnd


;--------------------------------
;Descriptions

        LangString DESC_SecCore ${LANG_KOREAN} "${PRODUCT_NAME} 실행 파일을 설치 폴더로 복사합니다."
        LangString DESC_SecShortcuts ${LANG_KOREAN} "시작 메뉴에 프로그램 그룹을 등록합니다."

        !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
                !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore)
                !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} $(DESC_SecShortcuts)
        !insertmacro MUI_FUNCTION_DESCRIPTION_END


;--------------------------------
; Uninstaller

Section "Uninstall"
        SetDetailsPrint textonly
        DetailPrint "Uninstalling Melon Player Shell Extensions..."
        SetDetailsPrint listonly

        IfFileExists $INSTDIR\Melon.exe melon_installed
                MessageBox MB_YESNO "It does not appear that Melon is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES melon_installed
                Abort "Uninstall aborted by user"
        melon_installed:

        StrCpy $Info "Melon Player 가 성공적으로 언인스톨되었습니다."




        ; Remove directories used
        SetDetailsPrint textonly
        DetailPrint "Deleting Files..."
        SetDetailsPrint listonly

        !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP

        ;Delete empty start menu parent diretories
        StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"

        startMenuDeleteLoop:
                RMDir /r $MUI_TEMP
                GetFullPathName $MUI_TEMP "$MUI_TEMP\.."

                IfErrors startMenuDeleteLoopDone

                StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
        startMenuDeleteLoopDone:
        
        RmDir /r $INSTDIR
        Delete "$DESKTOP\Melon Player.lnk"


        ; uninstall registry keys...
        SetDetailsPrint textonly
        DetailPrint "Deleting Registry Keys..."
        SetDetailsPrint listonly

        ReadRegStr $R0 HKCR ".dcf" ""
        StrCmp $R0 "Melon.Media" 0 +2
                DeleteRegKey HKCR ".dcf"

        DeleteRegKey HKCR "Melon.Media"

        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Melon"
        DeleteRegKey HKCU "Software\Melon"

        SetDetailsPrint both

SectionEnd

Function un.OnUninstSuccess

        HideWindow
        MessageBox MB_OK "$Info"
     
FunctionEnd



ex 4 : Filezilla installer

;NSIS Modern User Interface version 1.70
;FileZilla 3 installation script
;Written by Tim Kosse <mailto:tim.kosse@gmx.de>

;--------------------------------
;Include Modern UI

  !include "MUI.nsh"

;--------------------------------
;General

  ;Name and file
  Name "FileZilla 3 alpha 2"
  OutFile "FileZilla_3_alpha2_setup.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES\FileZilla 3"
  
  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\FileZilla 3" ""

;--------------------------------
;Variables

  Var MUI_TEMP
  Var STARTMENU_FOLDER

;--------------------------------
;Interface Settings

  !define MUI_ABORTWARNING

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_LICENSE "..\COPYING"
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY

  ;Start Menu Folder Page Configuration
  !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
  !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\FileZilla 3" 
  !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "FileZilla 3"
  !define MUI_STARTMENUPAGE_DEFAULTFOLDER "FileZilla 3"
  
  !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER

  !insertmacro MUI_PAGE_INSTFILES
  
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "FileZilla 3" SecMain

  SetOutPath "$INSTDIR"
  
  File "..\src\interface\FileZilla.exe"
  File "mingwm10.dll"
  File "..\GPL.html"

  SetOutPath "$INSTDIR\resources"
  File "..\src\interface\resources\*.xrc"
  File "..\src\interface\resources\*.png"
  File "..\src\interface\resources\*.xpm"

  SetOutPath "$INSTDIR\resources\16x16"
  File "..\src\interface\resources\16x16\*.png"

  SetOutPath "$INSTDIR\resources\32x32"
  File "..\src\interface\resources\32x32\*.png"
  
  ;Store installation folder
  WriteRegStr HKCU "Software\FileZilla 3" "" $INSTDIR
  
  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"

  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    
  ;Create shortcuts
  CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
  CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\FileZilla 3.lnk" "$INSTDIR\FileZilla 3.exe"
  
  !insertmacro MUI_STARTMENU_WRITE_END

SectionEnd

Section "Language files" SecLang

  SetOutPath "$INSTDIR\locales\de\LC_MESSAGES"
  File /oname=filezilla.mo "..\locales\de.mo"

SectionEnd

;--------------------------------
;Descriptions

  ;Language strings
  LangString DESC_SecMain ${LANG_ENGLISH} "Required program files."
  LangString DESC_SecLang ${LANG_ENGLISH} "Language files files."

  ;Assign language strings to sections
  !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${SecMain} $(DESC_SecMain)
    !insertmacro MUI_DESCRIPTION_TEXT ${SecLang} $(DESC_SecLang)
  !insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

  Delete "$INSTDIR\FileZilla.exe"
  Delete "$INSTDIR\mingwm10.dll"
  Delete "mingwm10.dll"
  Delete "$INSTDIR\GPL.html"
  Delete "$INSTDIR\resources\*.xrc"
  Delete "$INSTDIR\resources\*.png"
  Delete "$INSTDIR\resources\*.xpm"
  Delete "$INSTDIR\resources\16x16\*.png"
  Delete "$INSTDIR\resources\32x32\*.png"

  Delete "$INSTDIR\locales\de\LC_MESSAGES\filezilla.mo"

  Delete "$INSTDIR\Uninstall.exe"

  RMDir "$INSTDIR\locales\de\LC_MESSAGES"
  RMDir "$INSTDIR\locales\de"
  RMDir "$INSTDIR\locales"
  RMDir "$INSTDIR\resources\32x32"
  RMDir "$INSTDIR\resources\16x16"
  RMDir "$INSTDIR\resources"
  RMDir "$INSTDIR"

  
  !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
    
  Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
  Delete "$SMPROGRAMS\$MUI_TEMP\FileZilla 3.lnk"
  
  ;Delete empty start menu parent diretories
  StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
 
  startMenuDeleteLoop:
    RMDir $MUI_TEMP
    GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
    
    IfErrors startMenuDeleteLoopDone
  
    StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
  startMenuDeleteLoopDone:

  DeleteRegKey /ifempty HKCU "Software\FileZilla 3"

SectionEnd

ex 5 : ???

!include "MUI.nsh"

;--------------------------------
;Configuration

        !define COMP_NAME "DMI"
        !define APP_NAME "CQM"
        !define PRODUCT_NAME "CHOL 메신저"
        !define VERSION_MAJOR "3"
        !define VERSION_MINOR "97"
        !define DISPLAY_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}"
        !define CQM_CLASS "CQM Single"
        
        Name "${PRODUCT_NAME}"
        Caption "${PRODUCT_NAME} ${DISPLAY_VERSION} 설치"

        OutFile "cqm${VERSION_MAJOR}${VERSION_MINOR}.exe"
        
        CRCCheck on
        SetOverwrite on
        
        SetFont "굴림" 9
        
        ;인스톨 타입
        InstType "전체"
        InstType "기본"

        ;Folder-selection page
        InstallDir "$PROGRAMFILES\CHOL\Messenger"
        InstallDirRegKey HKEY_LOCAL_MACHINE "Software\${COMP_NAME}\${APP_NAME}" "InstallDir"
        
        BrandingText "Copyright ⓒ 2003 Dacom Multimedia Internet Corp. All Rights Reserved."

;--------------------------------
;Modern UI Configuration

        !define MUI_ABORTWARNING
        
        !define MUI_FONT_HEADER "굴림"
        !define MUI_FONTSIZE_HEADER "9"
        !define MUI_FONTSTYLE_HEADER "700"
        !define MUI_FONT_TITLE "굴림"
        !define MUI_FONTSIZE_TITLE "9"
        !define MUI_FONTSTYLE_TITLE "700"
        
        !define MUI_ICON "Install.ico"
        !define MUI_UNICON "Uninstall.ico"
        
        !define MUI_FINISHPAGE_RUN "$INSTDIR\CQM.exe"

;--------------------------------
;Pages

        !insertmacro MUI_PAGE_LICENSE "CHOL메신저이용약관.txt"
        !insertmacro MUI_PAGE_COMPONENTS
        !insertmacro MUI_PAGE_DIRECTORY
        !insertmacro MUI_PAGE_INSTFILES
        !insertmacro MUI_PAGE_FINISH

        !insertmacro MUI_UNPAGE_CONFIRM
        !insertmacro MUI_UNPAGE_INSTFILES
        
;Language
        !insertmacro MUI_LANGUAGE "Korean"
        
;------------------------------------------------------------------- 
; CloseWindow
; 
; Closes all running window instances of CLASS
; 

Function CloseWindow
        
        StrCpy $R0 "0"
        loop:
        IntCmp $R0 5 done 0 done
        FindWindow $R1 $0
        IntCmp $R1 0 done
        IsWindow $R1 0 done
                IntCmp $R0 0 0 0 AlertSkip
                        MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME}가 실행 중입니다. 설치를 위해서 ${PRODUCT_NAME}를 종료합니다."
                AlertSkip:
                SendMessage $R1 ${WM_DESTROY} 0 0
        Sleep 3000
        IntOp $R0 $R0 + 1
        Goto loop
        done:
        
FunctionEnd

Function BackupUser

        Pop $R0
        MessageBox MB_YESNO|MB_ICONINFORMATION "이전 CQM의 사용자 정보(버디 리스트, 친구 수첩) 폴더를 지금 백업하고$\n설치 후에 자동으로 복구하시겠습니까?(권장)" IDNO ExitBackupUser

        RetryBackupUser:
        CreateDirectory "$TEMP\CQMInstall.tmp"
        CopyFiles "$R0\User" "$TEMP\CQMInstall.tmp"

        IfErrors 0 SuccessBackupUser
        MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP "사용자 폴더를 백업하는 중에 에러가 발생했습니다." IDIGNORE ExitBackupUser IDRETRY RetryBackupUser
        Quit

        SuccessBackupUser:
        StrCpy $7 "$TEMP\CQMInstall.tmp"

        ExitBackupUser:

FunctionEnd
;------------------------------------------------------------------- 
; UninstallPrev
; 
; 호환되지 않는 이전 버전을 삭제한다
; 

Function UninstallPrev

        ; CQM 3.14 언인스톨
        ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\APP Paths\Cqm.exe" "Path"
        StrCmp $R0 "" RemovePrev
        IfFileExists "$R0\CQM.exe" 0 RemovePrev
        ReadRegStr $R1 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.14" "UninstallString"
        StrCmp $R1 "" NoPrev314
                Push $R0
                Call BackupUser
                MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 \
                        '기존 CQM 3.14를 먼저 언인스톨해야 합니다.$\n지금 언인스톨하시겠습니까?' IDNO QuitInstall
                ExecWait $R1
        NoPrev314:
        ; CQM 3.13 언인스톨
        ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\APP Paths\Cqm.exe" "Path"
        StrCmp $R0 "" RemovePrev
        IfFileExists "$R0\CQM.exe" 0 RemovePrev
        ReadRegStr $R1 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.13" "UninstallString"
        StrCmp $R1 "" NoPrev313
                Push $R0
                Call BackupUser
                MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 \
                        '기존 CQM 3.13를 먼저 언인스톨해야 합니다.$\n지금 언인스톨하시겠습니까?' IDNO QuitInstall
                ExecWait $R1
        NoPrev313:
        ; CQM 3.12 언인스톨
        ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\APP Paths\Cqm.exe" "Path"
        StrCmp $R0 "" RemovePrev
        IfFileExists "$R0\CQM.exe" 0 RemovePrev
        ReadRegStr $R1 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.12" "UninstallString"
        StrCmp $R1 "" NoPrev312
                Push $R0
                Call BackupUser
                MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 \
                        '기존 CQM 3.12를 먼저 언인스톨해야 합니다.$\n지금 언인스톨하시겠습니까?' IDNO QuitInstall
                ExecWait $R1
        NoPrev312:
        ; CQM 3.11 언인스톨
        ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\APP Paths\Cqm.exe" "Path"
        StrCmp $R0 "" RemovePrev
        IfFileExists "$R0\CQM.exe" 0 RemovePrev
        ReadRegStr $R1 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.11" "UninstallString"
        StrCmp $R1 "" NoPrev311
                Push $R0
                Call BackupUser
                MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 \
                        '기존 CQM 3.11를 먼저 언인스톨해야 합니다.$\n지금 언인스톨하시겠습니까?' IDNO QuitInstall
                ExecWait $R1
        NoPrev311:
        ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\APP Paths\Cqm.exe" "Path"
        StrCmp $R0 "" RemovePrev
        IfFileExists "$R0\CQM.exe" 0 RemovePrev

        ; 버전 검사
        StrCpy $R0 0
        StrCpy $R1 0
        ReadRegDWORD $R0 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "VersionMajor"
        ReadRegDWORD $R1 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "VersionMinor"
        IntCmpU $R0 3 0 UnknownPrev RemovePrev
        IntCmpU $R1 5 RemovePrev 0 RemovePrev
        UnknownPrev:
        MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 "호환되지 않는 이전 버전이 삭제되지 않았습니다. 이전 버전을 삭제한 후 설치하시기 바랍니다.$\n무시하고 계속하시겠습니까?" IDNO QuitInstall
        Return

        RemovePrev:
        DeleteRegKey    HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.14"
        DeleteRegKey    HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.13"
        DeleteRegKey    HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.12"
        DeleteRegKey    HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CQM3.11"

        Return

        QuitInstall:
        Quit
        
FunctionEnd

Function .onInit
        StrCpy $7 ""
        StrCpy $8 $INSTDIR
FunctionEnd

;------------------------------------------------------------------- 
; un.CloseWindow
; 
; Closes all running window instances of CLASS (uninstaller)
; 
; modifies no other variables

Function un.CloseWindow
        
        StrCpy $R0 "0"
        loop:
        IntCmp $R0 5 done 0 done
        FindWindow $R1 $0
        IntCmp $R1 0 done
        IsWindow $R1 0 done
                IntCmp $R0 0 0 0 AlertSkip
                        MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME}가 실행 중입니다. 언인스톨을 위해서 ${PRODUCT_NAME}를 종료합니다."
                AlertSkip:
                SendMessage $R1 ${WM_DESTROY} 0 0
        Sleep 3000
        IntOp $R0 $R0 + 1
        Goto loop
        done:
        
FunctionEnd

;--------------------------------
;Installer Sections

Section "!${PRODUCT_NAME} 설치" SecCopyUI
        SectionIn 1 2 RO

        ; 호환되지 않는 이전 버전 삭제
        Call UninstallPrev

        ; 실행 중인 CQM 종료
        StrCpy $0 "${CQM_CLASS}"
        Call CloseWindow

        ; 파일 복사

        SetOutPath "$INSTDIR\User"
        ; 이전 사용자 폴더 복구
        StrCmp $7 "" NoBackup
                CopyFiles "$7\User" "$INSTDIR"
                RmDir /r $7
                Goto RestoreEnd
        NoBackup:
                ; 설치 경로 변경시 이전 유저 정보 백업
                ClearErrors
                ReadRegStr $R0 HKEY_LOCAL_MACHINE "Software\${COMP_NAME}\${APP_NAME}" "InstallDir"
                IfErrors RestoreEnd
                StrCmp $8 $INSTDIR RestoreEnd
                MessageBox MB_YESNO|MB_ICONINFORMATION "설치 경로가 변경되었습니다.$\n이전 ${PRODUCT_NAME}의 사용자 정보(버디 리스트, 친구 수첩) 폴더를 현재 설치 경로로 복사하시겠습니까?(권장)" IDNO RestoreEnd
                CopyFiles "$8\User" "$INSTDIR"
        RestoreEnd:

        SetOutPath "$INSTDIR\Advertise"
        SetOutPath "$INSTDIR\Down"
        SetOutPath "$INSTDIR\PlugIn"
        File "PlugIn\*.*"

        SetOutPath "$INSTDIR\Sound"
        File "Sound\*.*"

        ; 프로그램 파일 생성
        SetOutPath "$INSTDIR"

        File "UpdateCQM.exe"
        File "cqm.ini"
        File "CQMHelp.hlp"
        File "user.txt"
        File "mfc42.dll"
        File "msvcrt.dll"
        File "..\Bin\CQMS.dll"
        File "..\Bin\CQMRes.dll"
        File "..\Bin\CQMP2P.dll"
        File "..\Bin\CQM.exe"
        ; IdleUI.dll이 남아 있으면...
        IFFileExists "$INSTDIR\IdleUI.dll" 0 NoIdleUI
                StrCpy $R0 "$INSTDIR\IdleUI.old"
                StrCpy $R1 "0"
                RenameIdleUI:
                Rename "$INSTDIR\IdleUI.dll" $R0
                IFErrors 0 DeleteIdleUI
                IntCmp $R1 100 NoIdleUI 0 NoIdleUI
                IntOp $R1 $R1 + 1
                StrCpy $R0 "$INSTDIR\IdleUI$R1.old"
                Goto RenameIdleUI
                DeleteIdleUI:
                Delete /REBOOTOK $R0
        NoIdleUI:
        ;File "..\Bin\IdleUI.dll"

        ; 언인스톨러 생성
        WriteUninstaller "$INSTDIR\Uninstall.exe"
        
        WriteRegStr HKEY_CURRENT_USER   "Software\dacom\CQM\Oem" "OemUrl" "http://cqm.chol.com"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\${COMP_NAME}\${APP_NAME}" "InstallDir" $INSTDIR
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\${COMP_NAME}\${APP_NAME}" "Version" "${APP_NAME}/${VERSION_MAJOR}.${VERSION_MINOR}"
        DeleteRegValue  HKEY_LOCAL_MACHINE "Software\${COMP_NAME}\${APP_NAME}" "Homepage"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\App Paths\CQM.exe" "" "$INSTDIR\CQM.exe"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\App Paths\CQM.exe" "Path" "$INSTDIR"
        WriteRegStr     HKEY_CLASSES_ROOT       "cqm" "" "URL:CHOL Messenger Protocol"
        WriteRegStr     HKEY_CLASSES_ROOT       "cqm" "URL Protocol" ""
        WriteRegStr     HKEY_CLASSES_ROOT       "cqm\DefaultIcon" "" '"$INSTDIR\CQM.exe",0'
        WriteRegStr HKEY_CLASSES_ROOT   "cqm\shell\open\command" "" '"$INSTDIR\CQM.exe" %1'
        ; 언인스톨 정보
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayName" "${PRODUCT_NAME}"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayIcon" '"$INSTDIR\Uninstall.exe",0'
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayVersion" "${DISPLAY_VERSION}"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "Publisher" "Dacom Multimedia Internet Inc."
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "HelpLink" "http://cqm.chol.com"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "URLInfoAbout" "http://cqm.chol.com"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "URLUpdateInfo" "http://cqm.chol.com"
        WriteRegDWORD HKEY_LOCAL_MACHINE        "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "VersionMajor" "${VERSION_MAJOR}"
        WriteRegDWORD HKEY_LOCAL_MACHINE        "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "VersionMinor" "${VERSION_MINOR}"
        WriteRegStr HKEY_LOCAL_MACHINE  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "UninstallString" '"$INSTDIR\Uninstall.exe"'

SectionEnd

Section "프로그램 그룹 생성" ProgramUI
        SectionIn 1 2
        SetShellVarContext all
        CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
        CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"                               "$INSTDIR\cqm.exe" "" "" 0
        CreateShortCut  "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} 언인스톨.lnk"          "$INSTDIR\uninstall.exe" "" "" 0
SectionEnd

Section "바탕화면 아이콘 생성" DesktopUI
        SectionIn 1
        SetShellVarContext all
        CreateShortCut  "$DESKTOP\${PRODUCT_NAME}.lnk"                                          "$INSTDIR\cqm.exe" "" "" 0
SectionEnd

Section "빠른 실행 아이콘 생성" QLaunchUI
        SectionIn 1
        ; 빠른 실행은 사용자별로 생성
        SetShellVarContext current
        CreateShortCut  "$QUICKLAUNCH\${PRODUCT_NAME}.lnk"                                      "$INSTDIR\cqm.exe" "" "" 0
SectionEnd

Section "자동 실행 설정" StartUpUI
        SectionIn 1
        ; 자동 실행 설정
        WriteRegDWORD   HKEY_CURRENT_USER "Software\Dacom\${APP_NAME}\connection" "윈도우시작" 1
        WriteRegStr             HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\run" "${APP_NAME}" "$INSTDIR\cqm.exe"
SectionEnd

;--------------------------------
;Descriptions

        LangString DESC_SecCopyUI ${LANG_KOREAN} "${PRODUCT_NAME} 실행 파일을 설치 폴더로 복사합니다."
        LangString DESC_ProgramUI ${LANG_KOREAN} "시작 메뉴에 프로그램 그룹을 등록합니다."
        LangString DESC_DesktopUI ${LANG_KOREAN} "바탕화면에 ${PRODUCT_NAME} 아이콘을 생성합니다."
        LangString DESC_QLaunchUI ${LANG_KOREAN} "작업 표시줄 빠른 실행에 ${PRODUCT_NAME} 아이콘을 생성합니다."
        LangString DESC_StartUpUI ${LANG_KOREAN} "윈도우즈 시작시에 ${PRODUCT_NAME}를 자동으로 실행합니다."

        !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
                !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI)
                !insertmacro MUI_DESCRIPTION_TEXT ${ProgramUI} $(DESC_ProgramUI)
                !insertmacro MUI_DESCRIPTION_TEXT ${DesktopUI} $(DESC_DesktopUI)
                !insertmacro MUI_DESCRIPTION_TEXT ${QLaunchUI} $(DESC_QLaunchUI)
                !insertmacro MUI_DESCRIPTION_TEXT ${StartUpUI} $(DESC_StartUpUI)
        !insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

        ; 실행 중인 CQM 종료
        StrCpy $0 "${CQM_CLASS}"
        Call un.CloseWindow

        ; 디렉토리 삭제
        RmDir /r "$INSTDIR\Advertise"
        RmDir /r "$INSTDIR\Plugin"
        RmDir /r "$INSTDIR\Sound"

        StrCpy $R0 "F"
        ; 특수 디렉토리 삭제
        RmDir "$INSTDIR\Down"
        IfFileExists "$INSTDIR\Down" 0 NoDown
        MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 "다운로드 폴더에 파일이 있습니다.$\n다운로드 폴더를 삭제하시겠습니까?" IDYES RmDown
                StrCpy $R0 "T"
                Goto NoDown
        RmDown:
                RmDir /r "$INSTDIR\Down"
        NoDown:

        RmDir "$INSTDIR\User"
        IfFileExists "$INSTDIR\User" 0 NoUser
        MessageBox MB_YESNO|MB_ICONINFORMATION|MB_DEFBUTTON2 "사용자 정보(버디 리스트, 친구 수첩) 폴더를 삭제하시겠습니까?" IDYES RmUser
                StrCpy $R0 "T"
                Goto NoUser
        RmUser:
                RmDir /r "$INSTDIR\User"
        NoUser:

        ; 파일 삭제
        Delete "$INSTDIR\CQM.exe"
        Delete "$INSTDIR\CQMHelp.hlp"
        Delete "$INSTDIR\IdleUI.dll"
        Delete "$INSTDIR\CQMS.dll"
        Delete "$INSTDIR\CQMRes.dll"
        Delete "$INSTDIR\CQMP2P.dll"
        Delete "$INSTDIR\mfc42.dll"
        Delete "$INSTDIR\msvcrt.dll"
        Delete "$INSTDIR\user.txt"
        Delete "$INSTDIR\UpdateCQM.exe"
        Delete "$INSTDIR\Uninstall.exe"
        Delete "$INSTDIR\*.*"

        StrCmp $R0 "T" NoInst
                RMDir "$INSTDIR"
        NoInst:

        ; 빠른 실행 아이콘 삭제
        SetShellVarContext current
        Delete "$QUICKLAUNCH\${PRODUCT_NAME}.lnk"

        ; 데스크탑 아이콘 삭제
        SetShellVarContext all
        Delete "$DESKTOP\${PRODUCT_NAME}.lnk"

        ; 프로그램 그룹 삭제
        Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
        Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} 언인스톨.lnk"
        RMDir "$SMPROGRAMS\${PRODUCT_NAME}"

        ; 레지스트리 정보 삭제
        DeleteRegKey    HKEY_LOCAL_MACHINE      "Software\Microsoft\Windows\CurrentVersion\App Paths\CQM.exe"
        DeleteRegValue  HKEY_LOCAL_MACHINE      "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" "${APP_NAME}"
        DeleteRegKey    HKEY_LOCAL_MACHINE      "Software\${COMP_NAME}\${APP_NAME}"
        DeleteRegKey    HKEY_CURRENT_USER       "SOFTWARE\dacom\${APP_NAME}"
        DeleteRegKey    HKEY_CLASSES_ROOT       "cqm"

        ; 언인스톨 정보 삭제
        DeleteRegKey    HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"

    IfRebootFlag "" UnNoReboot
        MessageBox MB_OKCANCEL "$(^Name)의 제거를 완료하기 위해서는 시스템을 다시 시작해야 합니다. 지금 재부팅 하시겠습니까?" IDCANCEL UnNoReboot
                Reboot
    UnNoReboot:

SectionEnd


Reference

반응형
Comments