U E D R , A S I H C RSS

NSIS/Reference


주로 이용하는 것들 (NSIS/예제1, NSIS/예제2, NSIS/예제3 을 작성할 때 필요한 것 정도의 수준)위주로 정리. 좀 더 자세한 것에 대해서는 원문을 참조.


1. Installer attributes

1.1. General

attribute parameter example 설명
OutFile "example.exe" 인스톨러의 화일 이름
Name "zp_exam_project" 인스톨러 이름 (보통은 인스톨하려는 프로그램의 이름)
Caption "zeropage" 인스톨러의 titlebar 관련 caption. default는 "Name Setup"
SubCaption 0 ": 라이센스기록" 인스톨러 각 페이지 관련 부타이틀
0 - License Agreement
1 - Installation Options
2 - Installation Directory
3 - Installing Files
4 - Completed
BrandingText "ZeroPage Installer System v1.0" 인스톨러 하단부에 보여지는 텍스트
Icon "setup.ico" Installer 의 아이콘. 반드시 32*32*16 color 이여야 한다.
WindowIcon on | off Icon 을 표시할 것인지 말것인지 결정
BGGradient 000000 308030 FFFFFF 그라데이션 배경화면의 이용. 16진수 RGB값으로 표현
기본인자는 off | topcolor bottomcolor captiontextcolor | notext
MiscButtonText "이전" "다음" "취소" "닫기" 각 버튼들에 대한 text 설정 (순서대로)
InstallButtonText "설치 Install 버튼에 대한 text 의 설정

1.2. Install Directory

attribute parameter example 설명
InstallDir $PROGRAMFILES\example 기본 설치 디렉토리
InstallDirRegKey . .

1.3. License Page - 라이센스 관련 페이지에 쓰이는 속성들

attribute parameter example 설명
LicenseText "인스톨 하기 전 이 문구를 읽어주십시오" "동의합니다" license text 에서의 구체적 문구
인자는 text buttontext. buttontext 가 없으면 기본적으로 "I Agree"
LicenseData zp_license.txt 해당 license 문구 텍스트가 담긴 화일

1.4. Component Page - 설치할 항목을 선택하는 페이지에 쓰이는 속성들

attribute parameter example 설명
ComponentText "해당 컴포넌트를 골라주세요" 기본인자는 text subtext1 subtext2
component list 관련 표시될 텍스트.
InstType "Full Install" Install 관련 component type 에 대한 정의. 순서대로 1,2,3,4...8 까지의 번호들이 매겨지며, 이는 추후 SectionIn 에서 해당 component 에 대한 포함관계시에 적용된다.
EnabledBitmap enabled.bmp component 선택 관련 체크된 항목 bitmap. 20*20*16 color bmp format.
DisabledBitmap disabled.bmp component 선택 관련 체크되지 않은 항목 bitmap. 20*20*16 color bmp format.
SpaceTexts "필요요구용량" "이용가능한용량" "Space required:", "Space available:" 에 대한 표현 관련 텍스트

1.5. Directory Page - 설치할 디렉토리를 선택하는 페이지에 쓰이는 속성들

attribute parameter example 설명
DirShow show 디렉토리 설정 화면 표시여부
DirText "설치할 디렉토리를 골라주십시오" "인스톨할 디렉토리설정" "폴더탐색" 디렉토리 선택 페이지에서의 각각 문구들의 설정.
AllowRootDirInstall false 루트디렉토리에 설치할 수 있도록 허용할것인지에 대한 여부

1.6. Install Page - 실질적인 Install 화면을 표시하는 페이지에 쓰이는 속성들

attribute parameter example 설명
InstallColors FFFF00 000000 foregroundcolor backgroundcolor. 또는 /windows 옵션을 이용가능
InstProgressFlags smooth colored smooth, colored. colored 를 설정시는 InstallColors 의 색으로 적용
AutoCloseWindow false 인스톨 완료시 자동으로 인스톨 윈도우를 닫을것인지에 대한 여부
ShowInstDetails show hide | show | nevershow . install 되는 화면을 보여줄 것인지에 대한 여부
DetailsButtonText "Show Details" "Show details" 버튼의 text 에 대한 설정
CompletedText "완료되었습니다" "Completed" 문구 text에 대한 설정

1.7. Uninstall

Uninstall 화면에 대한 설정들.
attribute parameter 설명
UninstallText text subtext .
UninstallIcon path_to_icon.ico 32*32*16 color icon
UninstallCaption caption .
UninstallSubCaption page_number subcaption 0: Confirmation, 1:Uninstalling Files, 2:Completed
ShowUninstDetails hide | show | nevershow .
UninstallButtonText button text .

2. Compiler Flags

  • SetOverwrite
  • SetCompress
  • SetDatablockOptimize
  • SetDateSave

3. Section

Section 은 설치를 위한 일종의 하나의 모듈, 컴포넌트이다. Section 과 InstType 은 다르다.
InstType 하나당 여러개의 Section 묶음으로 되어있는 것이다. 사용자는 각각의 Section 에 대해 활성/비활성화 함으로서 설치될 모듈들을 고를 수 있다.

단, Uninstall Section은 언인스톨을 위한 특수한 Section이다.

attribute parameter example 설명
Section "ZPTest Defaults Modules (required)" Section 의 시작을 알린다. Section의 이름을 설정. 만일 Section의 이름이 비어있거나 '-'로 시작되는 경우에는 사용자가 선택할 수 없고, 볼 수도 없다. (즉, 반드시 필요한 Section에 대해). 그리고 가장 처음으로 선언되는 Section은 default Section이 되며 역시 필수 Section이 된다.
SectionIn 123 or 1-2-3 위에 적은 InstType 에 포함되는 Type의 번호를 넣는다.
SectionEnd Section의 끝을 알리는 attribute
SectionDivider " additional utilities " 각 Section 간 절취선. 중간에 text 넣기 가능
AddSize 1000 kb 단위. 각 Section당 필요한 용량에 대해 적어준다.

4. Function (함수)

함수는 Section과 비슷한 역할을 한다. 하지만, 다른 점이라면 함수는 installer 에서 직접 선택하여 호출하는것이 아니라, Section 에서 Call 명령어를 통해 호출되어 인스톨러의 기능의 일부들을 보충하는 역할을 한다. 그리고 특별한 경우로써, Callback Function들이 있다.

4.1. 유의 사항

함수들은 Section 이나 Function 안에서 정의되면 안된다. 함수들중 '.' 으로 시작되는 함수들은 기본적으로 Callback function으로 예약되어있다.

함수중 'un.' 으로 시작하는 것들은 일반적으로 Uninstaller를 위한 함수들이다. Uninstall Section이 정의되어있지 않은 경우, 호출되지 않을 것이다.

1. attribute

Function function_name 하당 함수이름으로 함수 선언
FunctionEnd 함수의 끝을 알린다.

5. Labels

Label은 Goto 명령어나 기타 조건제어문들 (IfErrors, MessageBox, IfFileExists, StrCmp 등)을 위해 이용한다.
Label 은 반드시 Section 이나 Function 내에 존재해야 한다. Label 은 해당 Section 과 Function 내에서만 그 범위를 가진다.

선언은 간단하다.
~cpp 
MyLabel:

6. Instructions

실제 인스톨 행위를 하기 위한 명령어들이다.

6.1. Basic

Instruction parameter 설명
SetOutPath outpath output path를 설정한뒤 ($OUTDIR), 만일 해당 path가 존재하지 않으면 만든다. 반드시 full-pathname 이여야 하며 일반적으로 $INSTDIR 이 이용된다.
File (/r file|wildcard ...) | /oname=file.data infile.dat해당 output path ($OUTDIR)에 화일들을 추가한다. 와일드카드 (?, *) 등을 이용할 수 있다. 만일 /r 옵션을 이용할 경우, 해당 화일들와 디렉토리들이 재귀적으로 추가된다. (rm -rf의 'r' 옵션의 의미를 생각하길)
Exec command 특정 프로그램을 실행하고 계속 다음진행을 한다. $OUTDIR 은 작업디렉토리로 이용된다. ex) Exec '"$INSTDIR\command.exe" parameters'
ExecWait command user_var(exit code) 특정 프로그램을 실행시키고, 종료될 때까지 기다린다.
ExecShell action command parameters SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED ShellExecute를 이용, 프로그램을 실행시킨다. action은 보통 'open', 'print' 등을 말한다. $OUTDIR 은 작업디렉토리로 이용된다.
Rename /REBOOTOK source_file dest_file 화일이름을 변경한다. (또는 Move 한다.)
Delete /REBOOTOK file 화일을 삭제한다. 와일드카드 사용가능.
RMDir /r directory 해당 디렉토리를 지운다. (full-path여야함)

6.2. Registry/INI

WriteRegStr root_key subkey key_name value 레지스트리에 기록. root키의 경우 다음이 가능. HKCR - HKEY_CLASSES_ROOT
HKLM - HKEY_LOCAL_MACHINE
HKCU - HKEY_CURRENT_USER
HKU - HKEY_USERS
HKCC - HKEY_CURRENT_CONFIG
HKDD - HKEY_DYN_DATA
HKPD - HKEY_PERFORMANCE_DATA
WriteRegExpandStr . .
WriteRegDWORD . .
WriteRegBin . .
WriteINIStr ini_filename section_name entry_name value ini 화일에 기록. section_name entry_name=value 식으로 저장됨
ReadRegStr . .
ReadRegDWORD . .
ReadINIStr . .
ReadEnvStr . .
ExpandEnvStrings . .
DeleteRegValue . .
DeleteRegKey /ifempty root_key subkey 레지스트리 키 삭제
EnumRegKey . .
EnumRegValue . .
DeleteINISec . .
DeleteINIStr . .

6.3. Advanced

CreateDirectory path_to_create 디렉토리 생성
CopyFiles . .
SetFileAttributes . .
CreateShortCut . .
GetFullPathName . .
SearchPath . .
GetTempFileName . .
CallInstDLL . .
RegDLL . .
UnRegDLL . .
GetDllVersion . .
GetDLLVersionLocal . .
GetFileTime . .
GetFileTimeLocal . .

6.4. Branching/etc

Goto . .
Call . .
Return . .
IfErrors . .
ClearErrors . .
SetErrors . .
FindWindow . .
SendMessage . .
IsWindow . .
IfFileExists . .
MessageBox . .
StrCmp . .
IntCmp . .
IntCmpU . .
Abort . .
Quit . .
GetFunctionAddress . .
GetLabelAddress . .
GetCurrentAddress . .

6.5. File/directory i/o

FindFirst . .
FindNext . .
FindClose . .
FileOpen . .
FileClose . .
FileRead . .
FileWrite . .
FileReadByte . .
FileWriteByte . .
FileSeek . .

6.6. Misc

SetDetailsView . .
SetDetailsPrint . .
SetAutoClose . .
DetailPrint . .
Sleep . .
BringToFront . .
HideWindow . .

6.7. Strings

StrCpy . .
StrLen . .

6.8. Stack

Push . .
Pop . .
Exch . .

6.9. Integers

IntOp . .
IntFmt . .

6.10. Reboot

Reboot . .
IfRebootFlag . .
SetRebootFlag . .

6.11. Uninstall

  • WriteUninstaller - uninstller 화일이름 설정. 보통 uninstall.exe 라고 써주면 됨. 단, 레지스트리에 등록시키는 화일과 같아야 한다.

7. Variables

이용가능한 변수들.

7.1. modifiable variables that are usable in Instructions

  • $INSTDIR - 인스톨 디렉토리.
  • $OUTDIR - 현재의 Output directory. SetOutPath 로 설정가능
  • $0 ~ $9, $R0 ~ $R9 - 사용자 변수들. 다른 명령어들의 결과값 등을 받을 때 이용할 수 있다.
  • $CMDLINE

7.2. constant variables that are usable in Instructions and InstallDir

  • $PROGRAMFILES - program files 디렉토리. (보통 C:\Program Files) 실행시 탐색된다.
  • $DESKTOP - 윈도우 데스트톱 디렉토리 (보통 C:\windows\desktop) 실행시 탐색된다.
  • $EXEDIR - installer 가 실행되는 위치
  • $WINDIR - windows 디렉토리 (보통 C:\windows , C:\winnt) 실행시 탐색된다.
  • $SYSDIR - windows system 디렉토리 (보통 C:\windows\system, C:\winnt\system32) 실행시 탐색된다.
  • $TEMP - 시스템 임시 디렉토리 (보통 C:\windows\temp) 실행시 탐색됨.
  • $STARTMENU - 시작메뉴 folder. (CreateShortCut 을 이용, 시작메뉴에 등록시 유용하다.)
  • $SMPROGRAMS - 시작메뉴 programs folder (보통 $STARTMENU\Programs 대신 이용)
  • $SMSTARTUP - 시작메뉴 programs/startup folder. 즉, '시작프로그램'
  • $QUICKLAUNCH - IE4 이상. 퀵런치
  • $HWNDPARENT - parent window의 HWND 에 대한 10진수값.
  • $$ - '$' 표현시..

7.3. usable anywhere in a string

  • $\r - '\r'
  • $\n - '\n'
  • ${SYMBOL}

8. Uninstall Section

Section 중 'Uninstall' 의 이름을 가진 Section 은 uninstaller를 위한 Section이다. 이 Section 에서는 화일들, 레지스트리 등을 시스템으로부터 제거하는 일을 해야한다.
ex)
~cpp 
        Section "Uninstall"
          Delete $INSTDIR\Uninst.exe ; delete self (see explanation below why this works)
          Delete $INSTDIR\myApp.exe
          RMDir $INSTDIR
          DeleteRegKey HKLM SOFTWARE\myApp
        SectionEnd

uninstaller 는 uninstall을 위해 시스템 임시디렉토리에 자기자신을 복사하므로, Uninstall Section 에서는 반드시 Uninst.exe를 지워준다.

9. Callback functions

특정 이벤트 발생시에 호출되는 함수들이다.

9.1. Install callback

인스톨 과정중 발생하는 이벤트에 대한 callback function.
  • .oninit
  • .onUserAbout
  • .onInstSuccess
  • .onInstFailed
  • .onVerifyInstDir
  • .onNextPage
  • .onPrevPage

9.2. Uninstall callback

언인스톨 과정중 발생하는 이벤트에 대한 callback function.
  • un.onInit
  • un.onUserAbout
  • un.onUninstSuccess
  • un.onUninstFailed
  • un.onNextPage

10. Compiler utility commands

C에서의 preprocessor 과 비슷하다. (하는 역할, 목적 면에서)
  • !system
  • !include
  • !cd
  • !packhdr

11. Compiler defines / conditional compilation

  • !define
  • !undef
  • !ifdef
  • !ifndef
  • !endif
  • !else
  • !macro
  • !macroend
  • !insertmacro

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:50
Processing time 0.1174 sec