출처: http://blog.naver.com/ysh0425a?Redirect=Log&logNo=14886206

Nullsoft SuperPiMP Install System (NSIS) 통합시디만들기

2005/07/11 07:47

복사 http://blog.naver.com/ysh0425a/14886206

Nullsoft SuperPiMP Install System (NSIS)

Applications packaged with NSIS supports the /S switch for a silent installation (the 'S' is case-sensitive)

Setup.exe /S

You can also use the /D switch to specify a destination drive/directory to install the files into:

Setup.exe /S /D=E:\Software\CDex

Software such as Winamp and CDex show a confirmation that install was successful at the end (CDex), or an "end-of-install" screen where you set file associations and settings (Winamp). I haven't found a way to bypass this yet, but it shouldn't affect the rest of the batch commands in any way.

» How do I find out if a setup package is made by NSIS?

Many NSIS packaged installers show the familiar small window at the center of your screen, such as Winamp and CDex:

NSIS Installer
click to enlarge
AND

출처 : http://nimto.tistory.com/678

헬마입니다.

이번에 회사에서 인스톨러 제작하면서 더욱 더 많은 것을 시도해보게 되는 것 같네요.

제작하는 인스톨러가 환영페이지 앞에 특정조건에 따라 비밀번호를 묻는 사용자페이지가 삽입되어 있었는데 이 페이지로 인해 환영페이지에서 무조건 뒤로 버튼이 출력되는 문제가 있었습니다.

NSIS 포럼에 가보니 역시 문제 해결책이 있더군요.

예제 코드는 환영 페이지 에서 뒤로 버튼을 감춥니다.

!define MUI_PAGE_CUSTOMFUNCTION_PRE Welcome_Pre
!insertmacro MUI_PAGE_WELCOME

<--- 위와 같이 조작하려는 페이지 앞에 사용자 함수를 호출하도록 선언합니다.

Function Welcome_Pre
  GetDlgItem $R0 $HWNDPARENT 3
  ShowWindow $R0 ${SW_HIDE}
FunctionEnd

<--- 위와 같이 함수를 작성하면 뒤로 버튼이 나타나지 않습니다.

PS. 뒤로 버튼 3
      다음 버튼 1
      취소 버튼 2 입니다.

AND

출처: http://nsis.sourceforge.net/Go_to_a_NSIS_page

Go to a NSIS page

From NSIS Wiki

Author: deguix (talk, contrib)


Contents

[hide]

Description

This function makes NSIS to go to a specified page relatively from the current page. Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) or the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page).

This function also allows InstallOptions and InstallOptionsEx to use its features so you can choose which controls will take the place of the default NSIS buttons.

Function Call

It doesn't use the stack because changing pages makes the code execution to stop. So instead it uses the variable "$R9".

StrCpy $R9 "(number|X)" ;Relative page number. See below.
Call RelGotoPage

Relative Page Number Values

  • If a number > 0: Goes foward that number of pages. Code of that page will be executed, not returning to this point. If it is bigger than the number of pages that are after that page, it simulates a "Cancel" click.
  • If a number < 0: Goes back that number of pages. Code of that page will be executed, not returning to this point. If it is bigger than the number of pages that are before that page, it simulates a "Cancel" click.
  • If X: Simulates a "Cancel" click. Code will go to callback functions, not returning to this point.
  • If 0: Continues on the same page. Code will still be running after the call.

Function Code

;----------------------------------------------------------------------------
; Title             : Go to a NSIS page
; Short Name        : RelGotoPage
; Last Changed      : 22/Feb/2005
; Code Type         : Function
; Code Sub-Type     : Special Restricted Call, One-way StrCpy Input
;----------------------------------------------------------------------------
; Description       : Makes NSIS to go to a specified page relatively from
;                     the current page. See this below for more information:
;                     "http://nsis.sf.net/wiki/Go to a NSIS page"
;----------------------------------------------------------------------------
; Function Call     : StrCpy $R9 "(number|X)"
;
;                     - If a number &gt; 0: Goes foward that number of
;                       pages. Code of that page will be executed, not
;                       returning to this point. If it excess the number of
;                       pages that are after that page, it simulates a
;                       "Cancel" click.
;
;                     - If a number &lt; 0: Goes back that number of pages.
;                       Code of that page will be executed, not returning to
;                       this point. If it excess the number of pages that
;                       are before that page, it simulates a "Cancel" click.
;
;                     - If X: Simulates a "Cancel" click. Code will go to
;                       callback functions, not returning to this point.
;
;                     - If 0: Continues on the same page. Code will still
;                        be running after the call.
;
;                     Call RelGotoPage
;----------------------------------------------------------------------------
; Author            : Diego Pedroso
; Author Reg. Name  : deguix
;----------------------------------------------------------------------------
 
Function RelGotoPage
  IntCmp $R9 0 0 Move Move
    StrCmp $R9 "X" 0 Move
      StrCpy $R9 "120"
 
  Move:
  SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd

Special Usage - Cancel Clicks Simulation

The .onUserAbort callback function (w/o MUI) and the function indicated by the !define MUI_CUSTOMFUNCTION_PRE (w/ MUI) are totally special in fact that they handle all "Cancel" and "X" clicks the user does, and secondly, that the code still runs if you run the RelGotoPage function, but goes to the page specified after the function is aborted. We can make this "Cancel" and "X" buttons to have a different effect like skipping to the next page, by using the following codes:

For All Pages

Default UI

Use the normal call that I described on the top of this page but on the function ".onUserAbort":

Function .onUserAbort
  StrCpy $R9 1 ;Goto the next page
  Call RelGotoPage
  Abort
FunctionEnd

Modern UI

Use the normal call that I described on the top of this page on the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT:

!insert "MUI.nsh" ;Required by MUI
 
!define MUI_CUSTOMFUNCTION_ABORT "FunctionName"
 
!insertmacro MUI_LANGUAGE "English" ;Required by MUI
 
Function FunctionName
  StrCpy $R9 1 ;Goto the next page
  Call RelGotoPage
  Abort
FunctionEnd

For One Page

Default UI

Use a variable to hold the page index inside the PreFunction of every page and before InstallOptions plugin first call inside every custom page main function, and compare this variable inside the ".onUserAbort" callback function. An example:

Page custom CustomPage
Page components Components_PreFunction
Page directory Directory_PreFunction
 
Function CustomPage
  StrCpy $R8 1 ;This is the first page
  InstallOptions::dialog "C:\MyDir\MyIOPage.ini"
  Pop $0
FunctionEnd
 
Function Components_PreFunction
  StrCpy $R8 2 ;This is the second page
FunctionEnd
 
Function Directory_PreFunction
  StrCpy $R8 3 ;This is the third page
FunctionEnd
 
Function .onUserAbort
  StrCmp $R8 1 0 End ;Compare the variable with the
                     ;page index of your choice
    StrCpy $R9 1
    Call RelGotoPage
    Abort
  End:
FunctionEnd

Modern UI

Use a variable to hold the page index inside the function indicated by each !define MUI_PAGE_CUSTOMFUNCTION_PRE of every page and before MUI_INSTALLOPTIONS_* macro first call inside every custom page main function (except for MUI_INSTALLOPTIONS_READ and MUI_INSTALLOPTIONS_WRITE macros), and compare this variable inside the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT. An example:

!include "MUI.nsh" ;Required by MUI
 
Page custom CustomPage
!define MUI_PAGE_CUSTOMFUNCTION_PRE Components_PreFunction
  !insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_PRE Directory_PreFunction
  !insertmacro MUI_PAGE_DIRECTORY
  
!define MUI_CUSTOMFUNCTION_ABORT "FunctionName"
!insertmacro MUI_LANGUAGE "English" ;Required by MUI
 
Function CustomPage
  StrCpy $R8 1 ;This is the first page
  InstallOptions::dialog "C:\MyDir\MyIOPage.ini"
  Pop $0
FunctionEnd
 
Function Components_PreFunction
  StrCpy $R8 2 ;This is the second page
FunctionEnd
 
Function Directory_PreFunction
  StrCpy $R8 3 ;This is the third page
FunctionEnd
 
Function FunctionName
  StrCmp $R8 1 0 End ;Compare the variable with the
                     ;page index of your choice
    StrCpy $R9 1
    Call RelGotoPage
    Abort
  End:
FunctionEnd
AND

출처: http://forums.winamp.com/showthread.php?postid=2056841

disable next button in a custom page

I am having a weird problem. I can not seem to be able to disable the install button in the following script. Just to make sure I am doing everything right I played with disabling the Cancel button and it worked! But I have no idea why the Install button is stubborn or is it me being stupid?

The script creates a simple license custom page and I want to disable the Install button until the I Agree Radio button is selected otherwise it needs to stay disabled.

PHP:

[Settings]
NumFields=3
[Field 1]
Type=Text
Left
=10
Right
=-10
Top
=10
Bottom
=110
State
=blabla
Flags
=MULTILINE|VSCROLL|READONLY

[Field 2]
Type=RadioButton
Text
=I AGREE
Flags
=NOTIFY
State
=0
Left
=10
Right
=110
Top
=120
Bottom
=128

[Field 3]
Type=RadioButton
Text
=I DO NOT AGREE
Flags
=NOTIFY
State
=1
Left
=10
Right
=110
Top
=131
Bottom
=139



 

PHP:

!define FILE_INI           "LicensePage.ini"
!include "MUI.nsh"
!include "Sections.nsh"
!include WinMessages.nsh

Page custom License LicenseLeave
""
!insertmacro MUI_PAGE_INSTFILES
OutFile
"test.exe"

Section "dummy"
SectionEnd


Function .onInit
       
!insertmacro MUI_INSTALLOPTIONS_EXTRACT ${FILE_INI}
FunctionEnd

Function License
       
!insertmacro MUI_HEADER_TEXT "License the product" "Please read the license carefully."
       
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\${FILE_INI}"
       
GetDlgItem $1 $HWNDPARENT 1
        EnableWindow
$1 0
        InstallOptions
::show
FunctionEnd

Function LicenseLeave
        ReadINIStr
$0 "$PLUGINSDIR\${FILE_INI}" "Settings" "State"
       
IntCmp $0 0 validate
        IntCmp
$0 2 I_AGREE
        IntCmp
$0 3 I_DO_NOT_AGREE
        Abort
        I_DO_NOT_AGREE
:
               
GetDlgItem $1 $HWNDPARENT 1
                EnableWindow
$1 0
                GetDlgItem
$1 $HWNDPARENT 2
                EnableWindow
$1 0
                Abort
        I_AGREE
:
               
GetDlgItem $1 $HWNDPARENT 1
                EnableWindow
$1 1
                GetDlgItem
$1 $HWNDPARENT 2
                EnableWindow
$1 1
                Abort
        validate
:
FunctionEnd

AND

출처: http://xozu.net/184

User inserted image

이번에 Vista 대응 작업을 하던 중 NSIS에서 설치 페이지를 뒤로 옮겨야 하는 일이 생겼다.
기본 Manual을 아무리 찾아봐도 안나오고 -_ㅠ
한참의 삽질 끝에 결국 google님의 힘을 빌어 찾아냈다.

아무래도 직접적인 페이지 이동 명령어는 존재하지 않고 SendMessage를 이용하여
뒤로 버튼을 누른 윈도우 메세지를 전달하는 듯 하다.

링크 : http://nsis.sourceforge.net/Go_to_a_NSIS_page

추가해줘야 할 Function

Function RelGotoPage
IntCmp $R9 0 0 Move Move
StrCmp $R9 "X" 0 Move
StrCpy $R9 "120"

Move:
SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd

사용 법 : $R9 스텍에 페이지 이동 수치를 입력 후 RelGotoPage를 호출

StrCpy $R9 "(number|X)" ;Relative page number. See below.
Call RelGotoPage

내 경우는 InstallPath 를 점검하여 설치 할 수 없는 폴더일 경우 다시 폴더 선택을 하도록 하는 처리가 필요했으며 파일 설치 직전에 $INSTDIR 를 체크하여 설치할 수 없는 폴더일 경우 -1 페이지 이동 처리를 했다. (파일 설치 페이지가 폴더 선택 페이지 바로 다음이었다.)

AND

출처; http://nsis.sourceforge.net/Contrib/InstallOptions/Readme.html

InstallOptions 2

Introduction

InstallOptions is a NSIS plugin which allows you to create custom pages for NSIS installers, to prompt the user for extra information.

InstallOptions will create a dialog which will be displayed inside the NSIS window. The controls on the dialog can be defined in an INI file.

NSIS 2 has a new page system, which allows you to add custom pages to your installer without messing with Prev/Next functions. With the new plugin system, you also don't have to worry anymore about extracting and deleting the DLL file. When you store the INI files in the plugins directory, NSIS will also delete them automatically.

This new version of InstallOptions has been designed for NSIS 2. It supports customized user interfaces and custom font and DPI settings.

INI File

The INI file has one required section. This section includes the number of controls to be created as well as general window attributes. The INI file also includes a variable number of Field sections which are used to create the controls to be displayed.

The required section is named "Settings". It can contain the following values:

NumFields (required) The number of control elements to be displayed on the dialog window.
Title (optional) If specified, gives the text to set the titlebar to. Otherwise, the titlebar text is not changed.
CancelEnabled (optional) If specified, overrides NSIS settings and enables or disables the cancel button. If set to 1, the cancel button will be enabled. If set to 0, the cancel button will be disabled.
CancelShow (optional) If specified, overrides NSIS settings and shows or hides the cancel button If set to 1, the cancel button will be shown. If set to 0, the cancel button will be hidden.
BackEnabled (optional) If specified, overrides NSIS settings and enables or disables the back button. If set to 1, the back button will be enabled. If set to 0, the back button will be disabled.
CancelButtonText (optional) Overrides the text for the cancel button. If not specified, the cancel button text will not be changed.
NextButtonText (optional) Overrides the text for the next button. If not specified, the next button text will not be changed.
BackButtonText (optional) Overrides the text for the back button. If not specified, the back button text will not be changed.
Rect (optional) Overrides the default rect ID to run over. This will make IO resize itself according to a different rect than NSIS's dialogs rect.
RTL (optional) If 1 is specified the dialog will be mirrored and all texts will be aligned to the right. Use NSIS's $(^RTL) to fill this field, it's the easiest way.
State (output) This is not something you have to supply yourself but is set by InstallOptions, before calling your custom page validation function, to the field number of the custom Button control (or other control having the Notify flag) the user pressed, if any.

Each field section has the heading "Field #" where # must be sequential numbers from 1 to NumFields. Each Field section can contain the following values:

Type (required) Type of control to be created. Valid values are "Label", "Text", "Password", "Combobox", "DropList", "Listbox", "CheckBox", "RadioButton", "FileRequest", "DirRequest" "Icon", "Bitmap", "GroupBox", "Link" or "Button".

A "Label" is used to display static text. (i.e. a caption for a textbox)
A "Text" and "Password" accept text input from the user. "Password" masks the input with * characters.
A "Combobox" allows the user to type text not in the popup list, a "Droplist" only allows selection of items in the list.
A "Listbox" shows multiple items and can optionally allow the user to select more than one item.
A "CheckBox" control displays a check box with label.
A "RadioButton" control displays a radio button with label.
A "FileRequest" control displays a textbox and a browse button. Clicking the browse button will display a file requester where the user can browse for a file.
A "DirRequest" control displays a textbox and a browse button. Clicking the browse button will display a directory requester where the user can browse for a directory.
An "Icon" control displays an icon. Use no Text to use the installer icon.
A "Bitmap" control displays a bitmap.
A "GroupBox" control displays a frame to group controls.
A "Link" control displays a static hot text. When the user clicks the control the contents of State (e.g. http://...) will be executed using ShellExecute. Alternatively State can be omitted and the NOTIFY flag used to have your NSIS script called. See the "NOTIFY" flag below for more information.
A "Button" control displays a push button that can be used in the same way as the "Link" control above.
Text (optional) Specifies the caption of a label, checkbox, or radio button control. For DirRequest control this specifies the title of the browse dialog. For icon and bitmaps control this specifies the path to the image.

Note: For labels, \r\n will be converted to a newline. To use a back-slash in your text you have to escape it using another back-slash - \\. Described below are NSIS functions for converting text to/from this format.
State (optional) Specifies the state of the control. This is updated when the user closes the window, so you can read from it from NSIS. For edit texts and dir and file request boxes, this is the string that is specified. For radio button and check boxes, this can be '0' or '1' (for unchecked or checked). For list boxes, combo boxes and drop lists this is the selected items separated by pipes ('|'). For Links and Buttons this can specify something to be executed or opened (using ShellExecute).

Note: For Text fields with the MULTILINE flag, \r\n will be converted to a newline. To use a back-slash in your text you have to escape it using another back-slash - \\. Described below are NSIS functions for converting text to/from this format.
ListItems (optional) A list of items to display in a combobox, droplist, or listbox.
This is a single line of text with each item separated by a pipe character '|'
MaxLen (optional) Causes validation on the selected control to limit the maximum length of text.
If the user specifies more text than this, a message box will appear when they click "OK" and the dialog will not be dismissed.
You should not use this on a "combobox" since the user can not control what is selected.
This should be set to a maximum of 260 for "FileRequest" and "DirRequest" controls.
Ignored on "Label" controls.
MinLen (optional) Causes validation on the selected control to force the user to enter a minimum amount of text.
If the user specifies less text than this, a message box will appear when they click "OK" and the dialog will not be dismissed.
Unlike MaxLen, this is useful for "Combobox" controls. By setting this to a value of "1" the program will force the user to select an item.
Ignored on "Label" controls.
ValidateText (optional) If the field fails the test for "MinLen" or "MaxLen", a messagebox will be displayed with this text.

Note: \r\n will be converted to a newline, two back-slashes will be converted to one - \\. Described below are NSIS functions for converting text to/from this format.
Left
Right
Top
Bottom
(required) The position on the dialog where this control appears. All sizes should be set in dialog units. To get the right dimensions for your controls, design your dialog using a resource editor and copy the dimensions to the INI file.

Note: You can specify negative coordinates to specify the distance from the right or bottom edge.

Note (2): For combobox or droplist, the "bottom" value is not used in the same way.
In this case, the bottom value is the maximum size of the window when the pop-up list is being displayed. All other times, the combobox is automatically sized to be one element tall. If you have trouble where you can not see the combobox drop-down, then check the bottom value and ensure it is large enough. A rough guide for the height required is the number of items in the list multiplied by 8, plus 20.

Note (3): FileRequest and DirRequest controls will allocate 15 dialog units to the browse button. Make this control wide enough the contents of the textbox can be seen.
Filter (optional) Specifies the filter to be used in the "FileRequest" control.
This is constructed by putting pairs of entries together, each item separated by a | character.
The first value in each pair is the text to display for the filter.
The second value is the pattern to use to match files.
For example, you might specify:
Filter=Text Files|*.txt|Programs|*.exe;*.com|All Files|*.*
If not specified, then the filter defaults to All Files|*.*

Note: you should not put any extra spaces around the | characters.
Root (optional) Used by DirRequest controls to specify the root directory of the search. By default, this allows the user to browse any directory on the computer. This will limit the search to a particular directory on the system.
Flags (optional) This specifies additional flags for the display of different controls. Each value should be separated by a | character, and you should be careful not to put any spaces around the | character.
Value Meaning
REQ_SAVE This causes "FileRequest" controls to display a Save As dialog. If not specified, an Open dialog is used.
FILE_MUST_EXIST Used by "FileRequest" to determine if the selected file must exist.
This only applies if an "Open" dialog is being displayed.
This currently does not force the file to exist other than through the browse button.
FILE_EXPLORER Used by "FileRequest", enables new file request look (recommended)
FILE_HIDEREADONLY Used by "FileRequest", hides "open read only" checkbox in open dialog.
WARN_IF_EXIST Used by "FileRequest" to display a warning message if the selected file already exists.
The warning message is only displayed for files selected with the browse button.
PATH_MUST_EXIST Used by "FileRequest" to force the path to exist. Prevents the user from typing a non-existent path into the browse dialog window.
This only validates path's selected with the browse button.
PROMPT_CREATE Used by "FileRequest" to display a warning if the selected file does not exist. However, it still allows the user to select the file.
This only displays the warning for files selected with the browse button.
Doesn't work along with REQ_SAVE.
RIGHT Used by "Checkbox" and "Radiobutton" controls to specify you want the checkbox to the right of the text instead of the left as is the default.
MULTISELECT Used by "Listbox" controls. Turns string selection on or off each time the user clicks or double-clicks a string in the list box. The user can select any number of strings. If this flag and EXTENDEDSELCT are not specified, only one item can be selected from the list.
EXTENDEDSELCT Used by "Listbox" controls. Allows multiple items to be selected by using the SHIFT key and the mouse or special key combinations. If this flag and MULTISELECT are not specified, only one item can be selected from the list.
RESIZETOFIT This causes "Bitmap" controls to resize the image to the size of the control. Also useful to support custom DPI settings. Without this, the image will be centered within the specified area.
TRANSPARENT Used by "Bitmap" controls. Hides every pixel with the same color as of the top left pixel. This allows to see-through to controls behind it. This flag doesn't work well with a combination of the RESIZETOFIT flag and bitmaps with more than 256 colors.
GROUP Add this flag to the first control of a group of controls to group them. Grouping controls allows you to create multiple groups of radio button and makes keyboard navigation using arrow keys easier.
NOTABSTOP Do not stop on the control when the user pressed the Tab key. Add NOTABSTOP to all controls of a group except the first one to allow navigation between groups with the Tab key.
DISABLED Causes a control to be disabled.
ONLY_NUMBERS Used by "Text" controls. Forces the user to enter only numbers into the edit box.
MULTILINE Used by "Text" controls. Causes the control to accept multiple-lines.
WANTRETURN Used by "Text" controls with multiple-line. Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into the text box.
NOWORDWRAP Used by "Text" controls with multiple-line. Disables the word-wrap that occurs when long lines are entered. Long lines instead scroll off to the side. Specifying the HSCROLL flag also has this effect.
HSCROLL Show a horizontal scrollbar. When used by "Text" controls with multiple-lines this also disables word-wrap.
VSCROLL Show a vertical scrollbar.
READONLY Used by "Text" controls. Prevents the user from entering or editing text in the edit control, but allow the user to select and copy the text.
NOTIFY Used by "Button", "Link", "CheckBox", "RadioButton", "ListBox" and "DropList" controls. Causes InstallOptions to call your NSIS custom page validation/leave function whenever the control's selection changes. Your validation/leave function can read the "State" value from the "Settings" section to determine which control caused the notification, if any, and perform some appropriate action followed by an Abort instruction (to tell NSIS to return to the page). The Contrib\InstallOptions folder contains an example script showing how this might be used.
TxtColor (optional) Used by Link controls to specify the foreground color of the text. Format: 0xBBRRGG (hexadecimal).

How to use

Modern UI

For information about using InstallOptions with the Modern UI, have a look at the Modern UI documentation.

Extract the INI File

First, you have to extract the INI files for the dialogs in the .onInit function:

Function .onInit

  InitPluginsDir
  File /oname=$PLUGINSDIR\test.ini test.ini

FunctionEnd

Call the DLL

You can call InstallOptions in a page function, check the NSIS documentation for information about the page system. Example:

Page custom SetCustom ValidateCustom

The InstallOptions DLL has three functions:

  • dialog - Creates the dialog immediately
  • initDialog - Creates the dialog in memory, does not show it
  • show - Shows a dialog created in memory

Usually, you only need to use the dialog function:

Function SetCustom ;FunctionName defined with Page command

  ;Display the Install Options dialog

  Push $R0

  InstallOptions::dialog $PLUGINSDIR\test.ini
  Pop $R0

FunctionEnd

Get the input

To get the input of the user, read the State value of a Field using ReadINIStr:

ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"

Note:

Some InstallOptions values are escaped (in a similar manner to "C" strings) to allow characters to be used that are not normally valid in INI file values. The affected values are:

  • The ValidateText field
  • The Text value of Label fields
  • The State value of Text fields that have the MULTILINE flag

The escape character is the back-slash character ("\") and the available escape sequences are:

"\\" Back-slash
"\r" Carriage return (ASCII 13)
"\n" Line feed (ASCII 10)
"\t" Tab (ASCII 9)

The following functions can be used to convert a string to and from this format:

; Convert an NSIS string to a form suitable for use by InstallOptions
; Usage:
;   Push <NSIS-string>
;   Call Nsis2Io
;   Pop <IO-string>
Function Nsis2Io
  Exch $0 ; The source
  Push $1 ; The output
  Push $2 ; Temporary char
  StrCpy $1 "" ; Initialise the output
loop:
  StrCpy $2 $0 1 ; Get the next source char
  StrCmp $2 "" done ; Abort when none left
    StrCpy $0 $0 "" 1 ; Remove it from the source
    StrCmp $2 "\" "" +3 ; Back-slash?
      StrCpy $1 "$1\\"
      Goto loop
    StrCmp $2 "$\r" "" +3 ; Carriage return?
      StrCpy $1 "$1\r"
      Goto loop
    StrCmp $2 "$\n" "" +3 ; Line feed?
      StrCpy $1 "$1\n"
      Goto loop
    StrCmp $2 "$\t" "" +3 ; Tab?
      StrCpy $1 "$1\t"
      Goto loop
    StrCpy $1 "$1$2" ; Anything else
    Goto loop
done:
  StrCpy $0 $1
  Pop $2
  Pop $1
  Exch $0
FunctionEnd

; Convert an InstallOptions string to a form suitable for use by NSIS
; Usage:
;   Push <IO-string>
;   Call Io2Nsis
;   Pop <NSIS-string>
Function Io2Nsis
  Exch $0 ; The source
  Push $1 ; The output
  Push $2 ; Temporary char
  StrCpy $1 "" ; Initialise the output
loop:
  StrCpy $2 $0 1 ; Get the next source char
  StrCmp $2 "" done ; Abort when none left
    StrCpy $0 $0 "" 1 ; Remove it from the source
    StrCmp $2 "\" +3 ; Escape character?
      StrCpy $1 "$1$2" ; If not just output
      Goto loop
    StrCpy $2 $0 1 ; Get the next source char
    StrCpy $0 $0 "" 1 ; Remove it from the source
    StrCmp $2 "\" "" +3 ; Back-slash?
      StrCpy $1 "$1\"
      Goto loop
    StrCmp $2 "r" "" +3 ; Carriage return?
      StrCpy $1 "$1$\r"
      Goto loop
    StrCmp $2 "n" "" +3 ; Line feed?
      StrCpy $1 "$1$\n"
      Goto loop
    StrCmp $2 "t" "" +3 ; Tab?
      StrCpy $1 "$1$\t"
      Goto loop
    StrCpy $1 "$1$2" ; Anything else (should never get here)
    Goto loop
done:
  StrCpy $0 $1
  Pop $2
  Pop $1
  Exch $0
FunctionEnd

Validate the input

If you want to validate the input on the page, for example, you want to check whether the user has filled in a textbox, use the leave function of the Page command and Abort when the validation has failed:

Function ValidateCustom

  ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
  StrCmp $R0 "" 0 +3
    MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your name."
    Abort

FunctionEnd

Return value

After you have called the DLL, InstallOptions adds one string to the stack, with one of the following values:

  • success - The user has pressed the Next button
  • back - The user has pressed the Back button
  • cancel - The user has pressed the Cancel button
  • error - An error has occurred, the dialog cannot be displayed.

Usually, you don't need to check this value, but you still have to remove it from the stack (have a look at the example above).

You only have to check this value if you need something really special, such as doing something when the user pressed the Back button.

Reserve files

If you are using BZIP2 (solid) compression, it's important that files which are being extracted in init- or page functions function are located before other files in the data block, because this will make your installer faster.

If there are File commands in your sections or functions above the init- or page functions, add ReserveFile commands above your sections and functions:

ReserveFile "test.ini"
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"

Fonts and colors

If you want to use custom fonts or colors on your InstallOptions dialogs, you should use the initDialog and show functions. initDialog creates the dialog in memory, but does not show it. After calling initDialog, you can set the fonts and colors, and call show to show the dialog. initDialog pushes the HWND of the custom dialog to the stack. To get the HWND of the controls use:

GetDlgItem (output var) (hwnd of the custom dialog) (1200 + Field number - 1)

Example of using a custom font:

Function FunctionName ;FunctionName defined with Page command

  ;Display the Install Options dialog

  Push $R0
  Push $R1
  Push $R2

    InstallOptions::initDialog /NOUNLOAD $PLUGINSDIR\test.ini
    Pop $R0

    GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1

    ;$R1 contains the HWND of the first field
    CreateFont $R2 "Tahoma" 10 700
    SendMessage $R1 ${WM_SETFONT} $R2 0

    InstallOptions::show
    Pop $R0

  Pop $R2
  Pop $R1
  Pop $R0

FunctionEnd

Version history

  • DLL version 2.42 (January 21st, 2005)
    • Added TRANSPARENT flag for BITMAP fields (funded by Chris Morgan)

Complete version history

Credits

Original version by Michael Bishop
DLL version by Nullsoft, Inc.
DLL version 2 by Amir Szekely, ORTIM, Joost Verburg
New documentation by Joost Verburg

License

Original version Copyright © 2001 Michael Bishop
DLL version 1 Copyright © 2001-2002 Nullsoft, Inc., ORTIM
DLL version 2 Copyright © 2003-2005 Amir Szekely, Joost Verburg, Dave Laundon

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented;
   you must not claim that you wrote the original software.
   If you use this software in a product, an acknowledgment in the
   product documentation would be appreciated but is not required.
2. Altered versions must be plainly marked as such,
   and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution
AND

출처: http://nsis.sourceforge.net/Add-on_Custom_Installer_Sample_/w_InstallOptions

Add-on Custom Installer Sample /w InstallOptions

From NSIS Wiki

Author: psyalien (talk, contrib)


Description

This is an installer I wrote to add on files to an already installed application called "APP" in this example. It uses a custom window defined in "installtype.ini" for InstallOptions.

The Script

;Author: Joey Cz.
;Contact: psyalien69 [at] yahoo [dot] com
 
 
; Modern interface settings
!include "MUI.nsh"
!include WinMessages.nsh
 
; Define your application name
!define APPNAME "Add-on Installer Sample"
!define APPNAMEANDVERSION "${APPNAME} 1.0"
!define APP_INST_DIR $8
;define global APP Database Dir alias
!define APP_DB_DIR $9
!define MUI_ABORTWARNING
 
; Window handle of the custom page
Var hwnd
; Install type variables
Var dbInst
Var fullInst
Var autoInst
 
; The name of the installer
Name "${APPNAMEANDVERSION}"
InstallDir ""
InstallDirRegKey HKLM "Software\${APPNAMEANDVERSION}" ""
 
; The installer file
OutFile "${APPNAMEANDVERSION} Installer.exe"
 
; Show install details
ShowInstDetails show
 
; Called before anything else as installer initialises
Function .onInit
	;NOTE:
	;	following is a sample for reading from the Registry
 
  ; read the APP installation directory from the registry
  ReadRegStr ${APP_INST_DIR} HKLM "Software\Vendor\App\Version" "InstallDir"
  ; read the database location if APP installation was found
  ReadRegStr ${APP_DB_DIR} HKCU "Software\Vendor\App\Version" "Database File Type"
 
  ; Check for APP installation existence
  StrCmp ${APP_INST_DIR} "" 0 NoAbortInst
         MessageBox MB_OK "APP installtion was not found.  Please install APP before runing this installer."
         Abort ; abort if APP installation is not found
  NoAbortInst:
 
  ; Check for APP Database dir existence
  StrCmp ${APP_DB_DIR} "" 0 NoAbortDb
         MessageBox MB_OK "APP Database location was not defined.  Please configure APP before runing this installer."
         Abort ; abort if APP installation is not found
  NoAbortDb:
 
  ; ExtrAPP InstallOptions files
  ; $PLUGINSDIR will automatically be removed when the installer closes
  InitPluginsDir
  File /oname=$PLUGINSDIR\test.ini "installtype.ini"
 
FunctionEnd
 
; NOTE :
; ************************
; Pages Displayed in order
; ************************
 
; Welcome Page
!insertmacro MUI_PAGE_WELCOME
 
; License Page
!insertmacro MUI_PAGE_LICENSE "License.txt"
 
; Our custom page
;Page custom ShowCustom LeaveCustom ": Select Install Type"
Page custom ShowCustom LeaveCustom
 
; APP Installation directory Page
!define MUI_DIRECTORYPAGE_VARIABLE ${APP_INST_DIR}
!define MUI_PAGE_HEADER_TEXT "APP Installation folder location."
!define MUI_PAGE_HEADER_SUBTEXT ""
!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the folder where APP has been installed.  If you are unsure where APP! has been installed, please keep the default value."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "APP Folder"
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!define MUI_PAGE_CUSTOMFUNCTION_PRE APPInstallDirectoryPage_Pre
!insertmacro MUI_PAGE_DIRECTORY
 
; APP Database directory Page
!define MUI_DIRECTORYPAGE_VARIABLE ${APP_DB_DIR}
!define MUI_PAGE_HEADER_TEXT "APP Database folder location."
!define MUI_PAGE_HEADER_SUBTEXT ""
!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the folder where APP! keeps its Database files.  If you are unsure where the APP! Database folder is, please keep the default value."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "APP Database Folder"
!define MUI_PAGE_CUSTOMFUNCTION_PRE APPDBDirectoryPage_Pre
!insertmacro MUI_PAGE_DIRECTORY
 
; Components Page
!define MUI_COMPONENTSPAGE_TEXT_TOP "Select the Components you want to install and uncheck the ones you you do not want to install. Click next to continue."
!define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_TITLE "Description"
!define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO "Description info"
!define MUI_PAGE_CUSTOMFUNCTION_PRE ComponentsPage_Pre
!insertmacro MUI_PAGE_COMPONENTS
 
; Install Files Page
!insertmacro MUI_PAGE_INSTFILES
 
; Finish Page
!define MUI_FINISHPAGE_RUN "${APP_INST_DIR}\APP.exe"
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "${APP_INST_DIR}\MyAddon\Readme.txt"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!insertmacro MUI_PAGE_FINISH
 
; Uninstall Confirm Page
!insertmacro MUI_UNPAGE_CONFIRM
 
; Uninstall Files Page
!insertmacro MUI_UNPAGE_INSTFILES
 
; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL
 
Function APPInstallDirectoryPage_Pre
 
    StrCmp $autoInst true 0 end
;        MessageBox MB_ICONEXCLAMATION|MB_OK "install dir PRE page"
        Abort
 
    end:
FunctionEnd
 
Function APPDBDirectoryPage_Pre
 
    StrCmp $autoInst true 0 end
;        MessageBox MB_ICONEXCLAMATION|MB_OK "db dir PRE page"
        Abort
 
    end:
 
FunctionEnd
 
Function ComponentsPage_Pre
 
    StrCmp $autoInst true 0 end
;        MessageBox MB_ICONEXCLAMATION|MB_OK "component PRE page"
        Abort
 
    end:
 
FunctionEnd
 
Function ShowCustom
  InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\test.ini"
  ; In this mode InstallOptions returns the window handle so we can use it
  Pop $hwnd
  
  !insertmacro MUI_HEADER_TEXT "Installation Type" "Please select the installation type, then click Next to proceede with the install."
 
  ; Now show the dialog and wait for it to finish
  InstallOptions::show
  ; Finally fetch the InstallOptions status value (we don't care what it is though)
  Pop $0
 
 
  
FunctionEnd
 
Function LeaveCustom
 
  ; At this point the user has either pressed Next or one of our custom buttons
  ; We find out which by reading from the INI file
  ReadINIStr $0 "$PLUGINSDIR\test.ini" "Settings" "State"
  StrCmp $0 0 validate  ; Next button?
  StrCmp $0 2 automaticRadio ; Automatic install
  StrCmp $0 3 customRadio  ; custom install
  StrCmp $0 7 comboBox ; Full install or DB
  Abort ; Return to the page
 
automaticRadio:
   GetDlgItem $1 $hwnd 1206 ; PathRequest control (1200 + field 7 - 1)
   EnableWindow $1 1
 
   Abort ; Return to the page
 
customRadio:
   WriteINIStr "$PLUGINSDIR\test.ini" "Field 7" "Flags" "DISABLED"
   GetDlgItem $1 $hwnd 1206 ; PathRequest control (1200 + field 7 - 1)
   EnableWindow $1 0
 
   Abort ; Return to the page
 
comboBox:
   Abort ; Return to the page
 
validate:
   
   ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 2" "State"
   StrCmp $0 1 automaticInst
   ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 3" "State"
   StrCmp $0 1 customInst
 
automaticInst:
   StrCpy $autoInst true
   Call AutomaticInstall
   Goto done
   
customInst:
   StrCpy $autoInst false
   Call CustomInstall
 
done:
FunctionEnd
 
Function AutomaticInstall
   ;MessageBox MB_ICONEXCLAMATION|MB_OK "You selected Automatic install"
 
   ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 7" "State"
   StrCmp $0 "Database Only" dbonly full
   full:
      StrCpy $fullInst true
      StrCpy $dbInst true
      Goto end
 
   dbonly:
      StrCpy $fullInst false
      StrCpy $dbInst true
 
   end:
FunctionEnd
 
Function CustomInstall
   ;MessageBox MB_ICONEXCLAMATION|MB_OK "You selected Custom install"
 
FunctionEnd
 
Section "Database" DBSection
 
	StrCmp $dbInst true dbFiles done
	dbFiles:
		;MessageBox MB_ICONEXCLAMATION|MB_OK "Installing DB Files"
 
		; Set Section properties
		SetOverwrite try
	
		; Set Section Files and Shortcuts
		SetOutPath "${APP_DB_DIR}\MyAddon\"
	
		File "Database\File1"
		File "Database\File2"
		File "Database\File3"
		
 
	done:
		;MessageBox MB_ICONEXCLAMATION|MB_OK "DONE Installing DB Files"
 
SectionEnd
 
SubSection /e "!Add-On Files" AddOnSection
	Section "Layout" LayoutSection
		StrCmp $fullInst true layout done
		layout:
			;MessageBox MB_ICONEXCLAMATION|MB_OK "Installing Layout Files"
			; LAYOUT SECTION
			; Set Section properties
			SetOverwrite try
	
			; Set Section Files and Shortcuts
			SetOutPath "${APP_INST_DIR}\Layout"
			File "Layout\File1"
			File "Layout\File2"
		done:
				;MessageBox MB_ICONEXCLAMATION|MB_OK "DONE Installing Layout Files"
 
	SectionEnd
 
	Section "Templates" TemplatesSection
		StrCmp $fullInst true templates done
		templates:
			;MessageBox MB_ICONEXCLAMATION|MB_OK "Installing Template Files"
			; TEMPLATE SECTION
			; Set Section Files and Shortcuts
			SetOutPath "${APP_INST_DIR}\Template\To Insured\"
			File "Template\File1"
			File "Template\File2"
			File "Template\File3"
		
		done:
			;MessageBox MB_ICONEXCLAMATION|MB_OK "DONE Installing Template Files"
	SectionEnd
 
	Section "Reports" ReportsSection
		StrCmp $fullInst true reports done
		reports:
			;MessageBox MB_ICONEXCLAMATION|MB_OK "Installing Reports Files"
			; REPORTS SECTION
			; Set Section Files and Shortcuts
			SetOutPath "${APP_INST_DIR}\Report"
			File "Report\File1"
		
		done:
			;MessageBox MB_ICONEXCLAMATION|MB_OK "DONE Installing Reports Files"
 
	SectionEnd
 
	Section "Documentation" DocumentationSection
		;MessageBox MB_ICONEXCLAMATION|MB_OK "Installing Documentation Files"
 
		; DOCUMENTATION SECTION
		; Set Section Files and Shortcuts
		SetOutPath "${APP_INST_DIR}\MyAddon\"
		File "Readme.txt"
		File "License.txt"
	SectionEnd
 
SubSectionEnd
 
Section -FinishSection
	; set the default layout for APP
	WriteRegStr HKCU "Software\Symantec\APP\Database" "Layout" "${APP_INST_DIR}\Layout\FILE1"
 
	; set the default database for APP
	WriteRegStr HKCU "Software\Symantec\APP\Database" "Database Name" "${APP_DB_DIR}\MyAddon\DBFILE"
 
	; set the default Word Procesor for APP
	WriteRegStr HKCU "Software\Symantec\APP" "WPDefaultDriver" "APPWrite"
 
	; set uninstall stuff
	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAMEANDVERSION}" "DisplayName" "${APPNAMEANDVERSION}"
	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAMEANDVERSION}" "UninstallString" "${APP_DB_DIR}\MyAddon\uninstall.exe"
	CreateDirectory "${APP_INST_DIR}\MyAddon"
	WriteUninstaller "${APP_INST_DIR}\MyAddon\uninstall.exe"
 
	CreateDirectory "$SMPROGRAMS\${APPNAMEANDVERSION}"
	CreateShortCut "$SMPROGRAMS\${APPNAMEANDVERSION}\Uninstall.lnk" "${APP_INST_DIR}\MyAddon\uninstall.exe"
	CreateShortCut "$SMPROGRAMS\${APPNAMEANDVERSION}\Operating Manual.lnk" "${APP_INST_DIR}\MyAddon\Installation and Operating Manual.doc"
	CreateShortCut "$DESKTOP\${APPNAMEANDVERSION}.lnk" "${APP_DB_DIR}\MyAddon\FILE"
	CreateShortCut "$SMPROGRAMS\${APPNAMEANDVERSION}\${APPNAMEANDVERSION}.lnk" "${APP_DB_DIR}\MyAddon\FILE"
        
SectionEnd
 
; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
	!insertmacro MUI_DESCRIPTION_TEXT ${DBSection} "MyAddon Database files for APP"
	!insertmacro MUI_DESCRIPTION_TEXT ${AddOnSection} "MyAddon Add-On files"
	!insertmacro MUI_DESCRIPTION_TEXT ${LayoutSection} "- Layout Files"
	!insertmacro MUI_DESCRIPTION_TEXT ${TemplatesSection} "- Template Files"
	!insertmacro MUI_DESCRIPTION_TEXT ${ReportsSection} "- Report Files"
	!insertmacro MUI_DESCRIPTION_TEXT ${DocumentationSection} "- Documentation Files"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
;Uninstall section
Section Uninstall
	; read APP Installation dir from registry
	ReadRegStr ${APP_INST_DIR} HKLM "Software\Vendor\APP\Version" "InstallDir"
	; read APP Database dir from registry
	ReadRegStr ${APP_DB_DIR} HKCU "Software\Vendor\APP\Version" "Database File Type"
 
	;Remove installer misc stuff from registry...
	DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAMEANDVERSION}"
	DeleteRegKey HKLM "SOFTWARE\${APPNAMEANDVERSION}"
 
	; Delete self
	Delete "${APP_INST_DIR}\MyAddon\uninstall.exe"
 
	; Clean up Documenation
	Delete "${APP_INST_DIR}\MyAddon\Readme.txt"
	Delete "${APP_INST_DIR}\MyAddon\License.txt"
	Delete "${APP_INST_DIR}\MyAddon\File1"
	Delete "${APP_INST_DIR}\MyAddon\File2"
  Delete "${APP_INST_DIR}\MyAddon\File3"
	; etc..
 
	RMDir "${APP_INST_DIR}\MyAddon"
 
 
	; Delete Shortcuts
	Delete "$DESKTOP\${APPNAMEANDVERSION}.lnk"
	Delete "$SMPROGRAMS\${APPNAMEANDVERSION}\${APPNAMEANDVERSION}.lnk"
	Delete "$SMPROGRAMS\${APPNAMEANDVERSION}\Uninstall.lnk"
 
	; Clean up MyAddon Insurance Database
	Delete "${APP_DB_DIR}\MyAddon\File1"
	; etc..
	
	; Clean up MyAddon Insurance Layout
	Delete "${APP_INST_DIR}\Layout\File1"
	; etc..
	
	; Clean up MyAddon Report files
	Delete "${APP_INST_DIR}\Report\File1"
	; etc..
	
	; Clean up MyAddon Templates
	Delete "${APP_INST_DIR}\Template\File1"
	; etc..
	
	; Remove remaining directories
	RMDir "$SMPROGRAMS\${APPNAMEANDVERSION}"
	RMDir "${APP_DB_DIR}"
	; etc..
	
SectionEnd

And following is "installtype.ini"

; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=7
Title=APP Add-On 1.0.0 Setup
NextButtonText=Next
BackButtonText=Back
 
[Field 1]
Type=Groupbox
Text=Select Install Type
Flags=NOTABSTOP
Left=30
Right=270
Top=0
Bottom=54
 
[Field 2]
Type=RadioButton
Text=Automatic
Flags=NOTIFY
State=1
Left=46
Right=122
Top=14
Bottom=25
 
[Field 3]
Type=RadioButton
Text=Custom
Flags=NOTIFY
Left=46
Right=122
Top=33
Bottom=43
 
[Field 4]
Type=Groupbox
Flags=NOTABSTOP
Left=30
Right=270
Top=59
Bottom=132
 
 
[Field 5]
Type=Text
Flags=MULTILINE|WANTRETURN|READONLY|NOWORDWRAP
State=Automatic Install :    (default)\r\n  - Full Install         :  Installs Database and Add-On Files\r\n  - Database Only :  Installs only the Database Files\r\n\r\nCustom Install:\r\n  - User driven customizable components installer
Left=35
Right=264
Top=68
Bottom=124
 
[Field 6]
Type=Groupbox
Text=Automatic
Left=150
Right=256
Top=8
Bottom=49
 
[Field 7]
Type=Droplist
Flags=NOTIFY
State=Full Install
ListItems=Full Install|Database Only
Left=156
Right=252
Top=18
Bottom=59
AND

출처: http://jgh0721.egloos.com/2501999


NSIS 에서 MUI 를 이용하여 사용자 페이지 추가하기

헬마입니다.

이번에 코덱팩에 몇 가지 사용자페이지들을 추가하면서 혹시 모르시는 분이 계실까봐 간단하게나마 글을 하나 써봅니다. 물론, 저의 형편없는 글솜씨로 더욱 모르시는분이 늘어나실지도 모르겠지만 ... ^^

  NSIS 는 기본적으로 몇 가지 종류의 정해진 화면을 제공합니다. 이러한 화면들은 설치관리자에서 거의 필수불가결로 쓰일만큼 필수적인 화면들이지요.  하지만, 언제나 이런 화면들만 이용해서 설치관리자를 만들 수는 없습니다. 우리들이 의도하는 모든 일을 처리할 수 있는것도 아니구요. 그래서 NSIS 는 이에 대한 대안으로 사용자가 직접 화면을 제작하여 나타내는 방법을 제공합니다. 지금부터 간단히 코덱팩에 쓰인 코드 일부분을 예제로 이용하여 사용자페이지를 하나 제작해보겠습니다.



1. 준비물 : Eclipse 나 HM Nis Edit 등 화면제작이 가능한 에디터 , 없어도 되지만 없으면 직접 위치 입력등을 계산해서 넣어줘야 하기때문에 매우 매우 귀찮아집니다 ㅠㅠ

  NSIS 의 사용자페이지는 특정한 문법을 갖춘 ini 파일이라고 할 수 있습니다.

  필수적으로 [Settings] 라는 섹션과 이 섹션에는 화면에 나타낼 컨트롤의 숫자를 나타내는 NumFields 라는 항목이 있어야 하며 여기에 적은 수 만큼 [Fields 1] [Fields 2] 이런식으로 섹션들이 이어집니다. NumFields 항목의 수와 [Fields #] 항목의 수는 반드시 일치해야합니다.
  [Fields #] 섹션에는 이 컨트롤의 종류를 나태는 Type 항목, 위치를 나타내는 Top,Left, Bottom, Right 항목, 화면에 나태낼 문자열등을 저장하는 Text(종류에 따라 다를 수 있습니다), 컨트롤의 상태를 저장하는 State 항목(필수 항목은 아닙니다) 등으로 구성되어 있습니다.

 자세한 사항은 InstallOptions 도움말을 참조하세요 ^^

 만들어보는 예제는 ffdshow 컴포넌트가 컴포넌트 페이지에서 선택되어 있다면 ffdshow 설정 페이지가 나타나도록 하는걸로 하겠습니다.

 일단 기본적인 사항으로 ffdshow 섹션이 있고 이 섹션에 섹션인덱스를 저장할 변수를 할당해놔야 합니다(그래야 나중에 컴포넌트 선택여부를 파악할 수 있습니다)

예)
Section 'ffdshow' SecFFDShow  ; SecFFDShow 가 섹션인덱스 변수입니다.
~~~
SectionEnd

  일단 제일 먼저 에디터를 이용하여 화면을 제작해야겠지요. 자신이 원하는 대로 HM Nis Edit 나 Eclipse 등을 이용하여 제작 후 ffdshow.ini 라는 파일로 저장하여 스크립트와 같은 위치에 놓습니다.

  화면 제작이 끝나면 이제 이 화면이 나타나는 기본적인 순서를 정해줘야 합니다. 여지껏 NSIS 스크립트를 작성하면서 페이지 순서다 하면 생각나시는 코드가 있을겁니다. 바로 Page 명령인데요. 이를 이용해서 기존에 작성했던 곳에 끼워넣으시면 됩니다. 예제에서는 ffdshow 등 컴포넌트를 선택한 후 ffdshow 선택여부에 따라 페이지를 보여주려고 하니 컴포넌트 페이지 다음에 추가하겠습니다.

예)
!insertmacro MUI_PAGE_COMPONENTS
Page custom ffdshow'' ' : ffdshow 초기 설정을 합니다'
!insertmacro MUI_PAGE_INSTFILES


  에디터에서 사용하는 대로 색상 넣으려는 벅차네요 ^^

  위와 같이 컴포넌트 선택페이지와 설치 페이지 사이에 제작한 페이지를 끼워넣습니다.

  custom 은 사용자 페이지를 사용하겠다는 뜻이고, ffdshow 는 이 페이지를 화면에 나타내야할 일이 생기면 호출될

함수 이름입니다. 후에 우리가 제작해야하며 실질적으로 이 함수에서 화면을 나타냅니다. 즉, 여기 순서에 있다고 무조

건 화면에 나타나는건 아닙니다. 여기에 끼워넣은건 단지 이 순서가 되면 함수를 호출해서 화면을 나타낼 기회를 부여

받는다고 생각하시면 될 것 같네요. 그다음 '' 는 원래 화면을 떠날 때, 즉 사용자가 다음 버튼을 누르면 호출될 함수 이

름을 적습니다. 없으면 위와 같이 '' 를 넣으면 됩니다. 예를 들어, 다음 버튼을 눌렀을 때 특정 조건을 검사하여 넘어가

지 못하게 하고 싶다거나 하면 함수를 만들고 '' 부분에 만든 함수 이름을 적어주시면 됩니다. 그다음은 딱 보면 감이

오듯이 제목표시줄에 나타낼 문자열입니다.

-
 자 이제, 화면 출력 순서도 정했으니 실질적으로 설치관리자에서 화면을 나타내야겠죠. 화면을 출력하는 과정은 두가

지입니다. 사실 엄밀히 말하면 NSIS 자체는 사용자 페이지를 나타내지 못합니다. InstallOptions 라는 플러그인을 이용

합니다. 그런데, 보통 페이지들은 아직 우리가 진짜 사용자 컴퓨터에 설치하려는 파일들이 설치되기 전입니다. 따라

서, 설치관리자가 실행되자마자 , 화면이 나타나기도 전에 InstallOptions 플러그인과 사용자페이지 ini 파일을 먼저 압

축을 풀어서 초기화를 해줘야합니다. 이일을 .onInit 라는 콜백함수에서 처리합니다. 이 함수는 설치관리자가 실행되면

그 어떠한 함수보다 먼저 실행됩니다.

예)

Function .onInit
 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ffdshow.ini" ; 사용자 페이지를 저장한 ffdshow.ini 파일을 읽어옵니다.
FunctionEnd


이런식으로 매크로를 이용하여 초기화하고 압축을 풀어줄 ini 파일 이름을 적어줍니다.

-
 이제 마지막 작업이 남았습니다. 실질적으로 화면을 나타내주는 함수를 작성해야합니다.

출력함수에서는 MUI_INSTALLOPTIONS_DISPLAY 라는 매크로를 사용하여 ini 파일이름을 입력하면 출력됩니다. 하

지만, 무턱대고 바로 이 매크로를 사용하면 우리의 의도(ffdshow 컴포넌트가 선택되면 출력) 에 어긋나게 선택되지 않

았어도 화면이 출력됩니다. 따라서 역시 다른 매크로나 함수를 이용하여 컴포넌트 선택여부를 판별해야합니다.

여기에는 LogicLib 라는 헤더파일을 이용하는 방법과 Sections 헤더에서 제공하는 SectionFlagIsSet 이라는 매크로를

이용하는 방법의 두 가지가 있습니다. 전자의 방법이 코드를 보기도 쉽고, 작성도 쉽기 때문에 이 방법을 사용하겠습니다.

LogicLib 를 사용하려면 LogicLib.nsh 를 포함시켜야합니다.

예)

Functionffdshow
 ${If} ${SectionIsSelected} ${SecFFDshow}
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY
'ffdshow.ini'
${EndIf}
FunctionEnd


위와 같이 작성하시면 됩니다. ffdshow 는 아까 page 명령에서 지정한 함수이름입니다.

 ${If} ${EndIf} 명령은 LogicLib 헤더에서 제공하는 제어문입니다. 이를 이용하면 Goto 등을 이용하지 않고 코드를 좀

더 간결하고 알아보기 쉽게 작성할 수 있습니다. ${SectionIsSelected} 는 LogicLib 에서 제공하는 ${If} 에서 사용하

는 검사명령으로 섹션이 선택되어 있으면 아래 문장등을 실행합니다.  ${SecFFDShow} 는 위에서 제일 처음 언급한

ffdshow 섹션에 대한 섹션인덱스 입니다.


그럼 부족한 글솜씨로 간단하게 적어보았습니다

이글이 조금이나마 도움이 되었으면 하며 더욱 자세한 사항은 InstallOptions 도움말을 찾아보세요. ^^


 
AND

출처: http://blog.naver.com/hoonlike71?Redirect=Log&logNo=28397650

NSIS_MUI_reference NSIS

2006/09/05 18:06

복사 http://blog.naver.com/hoonlike71/28397650

 

[모두 펼치기]   [모두 접기]

소개

NSIS 2 는 사용자 정의 인터페이스를 사용해서 인스톨러를 만들 수 있습니다. Modern UI 는 최근의 윈도에서 사용되는 마법사와 같은 형태의 인터페이스를 갖추고 있습니다.

이 새로운 인터페이스는 또한 새로운 기능페이지(환영,종료,시작메뉴) 와 컴포넌트 페이지의 설명영역을 제공합니다. 인터페이스와 그래픽은 모두 제공된 설정을 이용하여 조절할 수 있습니다.

Modern UI 매크로와 언어파일로 인터페이스 스크립트를 작성하는 것은 매우 쉽습니다. 이 문서는 Modern UI 스크립트를 작성하고 참조할 모든 설정 정보를 포함하고 있습니다.

중요: Modern UI 는 자신만의 매크로 시스템을 가지고 있기 때문에 기본 설정이나 많은 새로운 기능, 인터페이스 환경설정은 다르게 작용합니다. 따라서, LicenseText, Icon, CheckBitmap, InstallColors 등과 같은 커맨드를 사용하면 안됩니다.(주 - 즉, InstallColors 등과 같은 커맨드와 같은 결과를 Modern UI 매크로를 사용해서 해야합니다).

스크린 샷

사용법

Modern UI 는 매크로 시스템을 가지고 있고 인터페이스를 제어하기 위한 모든 코드가 이미 작성되어 있습니다.

새롭게 Modern UI 스크립트를 시작하거나 기존의 Classic UI 에서 업그레이드하려면 아래와 같은 방법을 따르십시요.

예제 스크립트를 살펴보면 Modern UI에 대하여 많은 도움이 될 것 입니다.

문법

몇 가지 선언 (예. MUI_COMPONENTSPAGE_SMALLDESC) 은 값을 필요로 하지 않으며 그것들은 참/거짓의 설정을 가집니다. 나머지 (예. MUI_UI) 것들은 값을 선언하는데 쓰입니다.

매개변수는 다음과 같은 형식을 따릅니다: required (option1 | option2) [optional]

선언된 설정에 대한 매개변수는 하나의 문자열안에 포함되어야 합니다:

!define MUI_COMPONENTSPAGE_SMALLDESC ; 값이 없음

!define MUI_UI "myUI.exe" ; MUI_UI에 myUI.exe 라는 값을 대입

!define MUI_INSTFILESPAGE_COLORS "FFFFFF 000000" ;두개의 설정값을 하나의 문자열로 묶음

어떤 값 (예. 문자열) 을 언어에 따라 지정하려면 언어 문자열을 지정하고(LangString 명령 사용) $(STRINGNAME)을 값으로 선언합니다. 라이센스 문자열에 대해서는 라이센스 언어 문자열(LicenselangString) 명령을 사용합니다.

Modern UI 문자열 안에서 " 를 추가하려면 반드시 $\" 와 같이 이스케이프 문자열을 사용해야합니다. 왜냐하면 Modern UI 매크로는 " 를 매개변수 분리자로 사용합니다.

1. 헤더 파일

!include "MUI.nsh"

MUI.nsh 는 Include 디렉토리안에 있기때문에 따로 경로를 설정할 필요가 없습니다.

2. 인터페이스 환경설정

인터페이스 설정은 반드시 페이지 매크로 앞에 설정해야합니다. 페이지 인터페이스 설정은 특정 형태의 모든 페이지들에 적용됩니다.

인터페이스 설정

범용 인터페이스 설정

MUI_ICON icon_file
인스톨러 아이콘을 설정합니다.
Default: ${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico

MUI_UNICON icon_file
언인스톨러 아이콘을 설정합니다.
Default: ${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico

MUI_HEADERIMAGE
페이지의 헤더 이미지를 나타냅니다.

MUI_HEADERIMAGE_BITMAP bmp_file
인스톨러 페이지들의 헤더에 나타낼 비트맵 이미지를 설정합니다. (권장 크기: 150x57 픽셀).
기본값: ${NSISDIR}\Contrib\Graphics\Header\nsis.bmp

MUI_HEADERIMAGE_BITMAP_NOSTRETCH
필드의 크기에 맞추어 비트맵 이미지를 늘리지 않습니다. 가지고 있는 이미지가 전체 공간을 사용하지 않을때만 이 옵션을 사용하십시요. 만약 정확히 맞는 크기의 이미지를 가지고 있다면 필드의 사이즈는 사용자의 DPI 설정이 변함에 따라 변하기 때문에 사용하면 안됩니다.

MUI_HEADERIMAGE_BITMAP_RTL bmp_file
RTL 언어를 사용할 때 인스톨러 페이지들에 나타낼 헤더 이미지를 설정합니다. (권장크기: 150x57 픽셀).
기본값: Non-RTL bitmap

MUI_HEADERIMAGE_BITMAP_RTL_NOSTRETCH
RTL 언어를 사용할 때 필드의 크기에 맞추어 비트맵 이미지를 늘리지 않습니다. 가지고 있는 이미지가 전체 공간을 사용하지 않을때만 이 옵션을 사용하십시요. 만약 정확히 맞는 크기의 이미지를 가지고 있다면 필드의 사이즈는 사용자의 DPI 설정이 변함에 따라 변하기 때문에 사용하면 안됩니다.

MUI_HEADERIMAGE_UNBITMAP bmp_file
언인스톨러 페이지들의 헤더에 나타낼 비트맵 이미지를 설정합니다. (권장크기: 150x57 픽셀.)
기본값: Installer header bitmap

MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH
필드의 크기에 맞추어 비트맵 이미지를 늘리지 않습니다. 가지고 있는 이미지가 전체 공간을 사용하지 않을때만 이 옵션을 사용하십시요. 만약 정확히 맞는 크기의 이미지를 가지고 있다면 필드의 사이즈는 사용자의 DPI 설정이 변함에 따라 변하기 때문에 사용하면 안됩니다.

MUI_HEADERIMAGE_UNBITMAP_RTL bmp_file
RTL 언어를 사용할 때 언인스톨러 페이지들에 나타낼 헤더 비트맵 이미지를 설정합니다. (권장크기: 150x57 픽셀).
기본값: Installer RTL header bitmap

MUI_HEADERIMAGE_UNBITMAP_RTL_NOSTRETCH
RTL 언어를 사용할 때 필드의 크기에 맞추어 비트맵 이미지를 늘리지 않습니다. 가지고 있는 이미지가 전체 공간을 사용하지 않을때만 이 옵션을 사용하십시요. 만약 정확히 맞는 크기의 이미지를 가지고 있다면 필드의 사이즈는 사용자의 DPI 설정이 변함에 따라 변하기 때문에 사용하면 안됩니다.

MUI_HEADERIMAGE_RIGHT
헤더 이미지를 왼편이 아닌 오른편에 출력합니다 (RTL 언어를 사용하면 오른편이 아닌 왼편에 출력됩니다).

MUI_BGCOLOR (색상: RRGGBBR 16진수)
환영, 종료 페이지의 헤더에 대한 배경 색을 지정합니다.
기본값: FFFFFF

인터페이스 자원 설정

MUI_UI ui_file
인터페이스에 적용할 대화상자 리소스 파일을 설정합니다. 이 파일을 변경하여 자신만의 UI를 만들 수 있습니다.
기본값: ${NSISDIR}\Contrib\UIs\modern.exe

MUI_UI_HEADERIMAGE ui_file
비트맵 컨트롤과 헤더 이미지를 위한 공간을 포함하는 대화상자 리소스 IDD_INST를 가진 인터페이스 파일을 설정합니다.
기본값: ${NSISDIR}\Contrib\UIs\modern_headerbmp.exe

MUI_UI_HEADERIMAGE_RIGHT ui_file
비트맵 컨트롤과 오른편에 헤더 이미지를 위한 공간을 포함하는 대화상자 리소스 IDD_INST를 가진 인터페이스 파일을 설정합니다.
기본값: ${NSISDIR}\Contrib\UIs\modern_headerbmpr.exe

MUI_UI_COMPONENTSPAGE_SMALLDESC ui_file
작은 설명 영역을 가진 사용자정의 대화상자 리소스 IDD_SELCOM 을 사진 인터페이스 파일을 설정합니다.
기본값: {NSISDIR}\Contrib\UIs\modern_smalldesc.exe

MUI_UI_COMPONENTSPAGE_NODESC ui_file
설명 영역이 없는 사용자정의 대화상자 리소스 IDD_SELCOM 을 사진 인터페이스 파일을 설정합니다.
기본값: {NSISDIR}\Contrib\UIs\modern_nodesc.exe

환영/종료 페이지 인터페이스 설정

MUI_WELCOMEFINISHPAGE_BITMAP bmp_file
환영, 종료 페이지에 대한 비트맵 이미지를 설정합니다 (권장 크기: 164x314 ).
기본값: ${NSISDIR}\Contrib\Graphics\Wizard\win.bmp

MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH
필드의 크기에 맞추어 비트맵 이미지를 늘리지 않습니다. 가지고 있는 이미지가 전체 공간을 사용하지 않을때만 이 옵션을 사용하십시요. 만약 정확히 맞는 크기의 이미지를 가지고 있다면 필드의 사이즈는 사용자의 DPI 설정이 변함에 따라 변하기 때문에 사용하면 안됩니다.

환영/종료 페이지 InstallOptions INI 설정

MUI_WELCOMEFINISHPAGE_INI ini_file
환영/종료 페이지에대한 InstallOptions INI 파일을 설정합니다.
기본값: ${NSISDIR}\Contrib\Modern UI\ioSpecial.ini

언인스톨러 환영/종료 페이지 설정

MUI_UNWELCOMEFINISHPAGE_BITMAP bmp_file
환영/종료 페이지에 대한 비트맵 이미지 (권장 크기: 164x314 픽셀).
기본값: ${NSISDIR}\Contrib\Graphics\Wizard\win.bmp

MUI_UNWELCOMEFINISHPAGE_BITMAP_NOSTRETCH
필드의 크기에 맞추어 비트맵 이미지를 늘리지 않습니다. 가지고 있는 이미지가 전체 공간을 사용하지 않을때만 이 옵션을 사용하십시요. 만약 정확히 맞는 크기의 이미지를 가지고 있다면 필드의 사이즈는 사용자의 DPI 설정이 변함에 따라 변하기 때문에 사용하면 안됩니다.

언인스톨러 환영/종료 페이지 INI 설정

MUI_UNWELCOMEFINISHPAGE_INI ini_file
언인스톨러 환영/종료 페이지에 대한 InstallOptions INI 파일을 설정합니다.
기본값: ${NSISDIR}\Contrib\Modern UI\ioSpecial.ini

라이센스 페이지 인터페이스 설정

MUI_LICENSEPAGE_BGCOLOR (/windows | /grey | (색상: RRGGBB 16진수))
라이센스 문자열상자의 배경색상을 지정합니다. 윈도 문자열 배경 색상을 설정하려면 /windows 를 사용하십시요(보통 하얀색). 윈도 배경 색을 지정하려면 /grey 를 사용하십시요(보통 회색).
기본값: /windows

컴포넌트 페이지 설정

MUI_COMPONENTSPAGE_CHECKBITMAP bitmap_file
컴포넌트 선택 트리뷰 선택 비트맵 이미지를 설정합니다.
기본값: ${NSISDIR}\Contrib\Graphics\Checks\modern.bmp

MUI_COMPONENTSPAGE_SMALLDESC
페이지 아래쪽에 작은 설명 영역을 설정합니다. 많은 섹션이 있으며 설명이 많지 않을때 사용하십시요.

MUI_COMPONENTSPAGE_NODESC
설명 영역을 없앱니다.

인스톨러 페이지 인터페이스 설정

MUI_INSTFILESPAGE_COLORS (/windows | (전경색: RRGGBB 16진수) (배경색: RRGGBB 16진수))
자세히 화면의 색상을 설정합니다. 기본 윈도 색상을 설정하려면 /windows 를 사용하십시요.
기본값: /windows

MUI_INSTFILESPAGE_PROGRESSBAR ("" | colored | smooth)
진행 막대의 스타일을 설정합니다. Colored 옵션은 MUI_INSTALLCOLORS 를 사용합니다.
기본값: smooth

인스톨러 종료 페이지 인터페이스 설정

MUI_FINISHPAGE_NOAUTOCLOSE
자동으로 종료 페이지로 넘어가지 않고 사용자가 설치기록을 점검할 수 있게합니다.

언인스톨러 종료 페이지 인터페이스 설정

MUI_UNFINISHPAGE_NOAUTOCLOSE
자동으로 종료페이지로 넘어가지 않고 사용자가 설치제거 기록을 살펴볼 수 있게합니다.

설치중단 경고 설정

MUI_ABORTWARNING
인스톨러를 닫으려고 하면 경고 메시지상자를 출력합니다.

MUI_ABORTWARNING_TEXT text
설치중단 경고 메시지 박스에 출력할 문자열을 지정합니다.

언인스톨러 중단 경고 설정

MUI_UNABORTWARNING
언인스톨러를 닫으려고 하면 경고 메시지상자를 출력합니다.

MUI_UNABORTWARNING_TEXT text
중단 경고 메시지 박스에 출력할 문자열을 지정합니다.

3. 페이지

사용하기 원하는 페이지를 설정하려면 아래와 같은 매크로를 추가합니다. 페이지들은 스크립트안에서 추가한 순서대로 정렬되어 나타납니다. 또한, 사용자정의 페이지를 추가하기 위해 매크로들 사이에 사용자정의 Page 명령을 추가할 수 있습니다. 사용자 정의 페이지에 더 많은 정보를 보려면 ...

특정 형태의 복수의 페이지를 추가할 수 있습니다 (예, 복수의 폴더를 선택할 때).

:

!insertmacro MUI_PAGE_LICENSE "License.rtf"

!insertmacro MUI_PAGE_COMPONENTS

 

Var STARTMENU_FOLDER

!insertmacro MUI_PAGE_STARTMENU "Application" $STARTMENU_FOLDER

시작메뉴 폴더 매크로를 사용하려면 시작메뉴 폴더 페이지에 대한 페이지 ID가 필요합니다. 시작메뉴폴더는 지정한 변수에 저장됩니다.

인스톨러 페이지
MUI_PAGE_WELCOME
MUI_PAGE_LICENSE
text/rtf_file
MUI_PAGE_COMPONENTS
MUI_PAGE_DIRECTORY
MUI_PAGE_STARTMENU
page_id variable
MUI_PAGE_INSTFILES
MUI_PAGE_FINISH

언인스톨러 페이지
MUI_UNPAGE_WELCOME
MUI_UNPAGE_CONFIRM
MUI_UNPAGE_LICENSE
text/rtf_file
MUI_UNPAGE_COMPONENTS
MUI_UNPAGE_DIRECTORY
MUI_UNPAGE_INSTFILES
MUI_UNPAGE_FINISH

페이지 설정

페이지 설정은 하나의 페이지에 적용되며 페이지 매크로를 추가하기 전에 설정해야 합니다. 만약 어떤 형태의 복수개의 페이지를 가지고 있기 이들 모두에 설정하려면 각 페이지 매크로에 앞서 설정을 추가해야합니다. 예:

;사용자가 플러그인 폴더를 선택할 수 있게 디렉토리 페이지 추가

;$PLUGINS_FOLDER 에 선택한 폴더 저장

 

Var PLUGINS_FOLDER

!define MUI_DIRECTORYPAGE_VARIABLE $PLUGINS_FOLDER

!insertmacro MUI_PAGE_DIRECTORY

알림: 이것은 인스톨러와 언인스톨러 페이지 설정사이에 차이가 없습니다.

범용 페이지 설정

MUI_PAGE_HEADER_TEXT text
페이지 헤더에 출력한 문자열을 설정합니다.

MUI_PAGE_HEADER_SUBTEXT text
페이지 헤더에 출력할 하위문자열을 설정합니다.

환영 페이지 설정

MUI_WELCOMEPAGE_TITLE title
페이지 상단에 출력할 제목을 설정합니다.

MUI_WELCOMEPAGE_TITLE_3LINES
제목 영역에 여백을 줍니다.

MUI_WELCOMEPAGE_TEXT text
페이지위에 출력할 문자열 설정합니다. 줄을 바꾸려면 \r\n 을 사용하십시요.

라이센스 페이지 설정

MUI_LICENSEPAGE_TEXT_TOP text
페이지 상단에 출력할 문자열을 설정합니다.

MUI_LICENSEPAGE_TEXT_BOTTOM text
페이지 하단에 출력할 문자열을 설정합니다.

MUI_LICENSEPAGE_BUTTON button_text
'I Agree' 버튼에 출력할 문자열을 설정합니다.

MUI_LICENSEPAGE_CHECKBOX
라이센스에 동의하기 위한 체크박스를 출력합니다.

MUI_LICENSEPAGE_CHECKBOX_TEXT text
라이센스에 동의하는 체크박스에 표시할 문자열을 설정합니다.

MUI_LICENSEPAGE_RADIOBUTTONS
라이센스 동의/동의 안함 사이에서 선택할 수 있는 두 개의 라디오 버튼을 출력합니다.

MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_ACCEPT text
라이센스에 동의하는 체크박스에 표시될 문자열을 설정합니다.

MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_DECLINE text
라이센스에 동의하지 않는 체크박스에 표시될 문자열을 설정합니다.

컴포넌트 페이지 설정

MUI_COMPONENTSPAGE_TEXT_TOP text
페이지 상단에 출력할 문자열.

MUI_COMPONENTSPAGE_TEXT_COMPLIST text
컴포넌트 리스트의 다음 버튼에 출력할 문자열.

MUI_COMPONENTSPAGE_TEXT_INSTTYPE text
설치타입 콤보 박스 다음에 출력할 문자열을 설정합니다.

MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_TITLE text
설명영역의 상단에 출력할 문자열을 설정합니다.

MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO text
섹션이 하나도 선택되지 않았을때 설명 영역에 출력할 문자열을 설정합니다.

디렉토리 페이지 설정

MUI_DIRECTORYPAGE_TEXT_TOP text
페이지 상단에 출력할 문자열을 설정합니다.

MUI_DIRECTORYPAGE_TEXT_DESTINATION text
대상 폴더 뼈대에 출력할 문자열을 설정합니다.

MUI_DIRECTORYPAGE_VARIABLE variable
선택한 폴더를 저장할 변수를 지정합니다.
기본값: $INSTDIR

MUI_DIRECTORYPAGE_VERIFYONLEAVE
선택한 폴더가 유효하지 않을 때 다음버튼을 비활성화하는 것이 아니라 유효하지 않은 폴더를 다루는 복귀함수에서 GetInstDirError 를 사용할 수 있게합니다.

시작 메뉴 폴더 페이지 설정

단축아이콘을 작성하기 위해 (CreateShortcut 사용) MUI_STARTMENU_WRITE_BEGIN 과 MUI_STARTMENU_WRITE_END 사이에 코드를 넣습니다 매크로:

!insertmacro MUI_STARTMENU_WRITE_BEGIN page_id

  ...create shortcuts...

!insertmacro MUI_STARTMENU_WRITE_END

The page ID should be the ID of the page on which the user has selected the folder for the shortcuts you want to write.

MUI_STARTMENUPAGE_TEXT_TOP text
페이지 상단에 출력할 문자열을 설정합니다.

MUI_STARTMENUPAGE_TEXT_CHECKBOX text
시작메뉴 폴더 생성을 비활성화하는 체크박스 다음에 출력할 문자열을 설정합니다.

MUI_STARTMENUPAGE_DEFAULTFOLDER folder
기본 시작메뉴 폴더를 설정합니다.

MUI_STARTMENUPAGE_NODISABLE
시작메뉴 단축아이콘을 비활성화하는 체크박스를 출력하지 않습니다.

MUI_STARTMENUPAGE_REGISTRY_ROOT root
MUI_STARTMENUPAGE_REGISTRY_KEY
key
MUI_STARTMENUPAGE_REGISTRY_VALUENAME
value_name
시작 메뉴 폴더를 저장할 레지스트리 키를 설정합니다. 이 페이지는 사용자의 기호를 기억하기 위해 사용합니다. 또한, 시작메뉴 폴더를 삭제하기 위해 언인스톨러에서도 사용해야합니다. 설치제거중에 이 키를 삭제하는 것을 잊으면 안됩니다.

언인스톨러의 경우, 시작 메뉴 폴더를 얻으려면 MUI_STARTMENU_GETFOLDER 매크로를 사용하세요:

!insertmacro MUI_STARTMENU_GETFOLDER page_id $R0

  Delete "$SMPROGRAMS\$R0\Your Shortcut.lnk"

설치 페이지 설정

MUI_INSTFILESPAGE_FINISHHEADER_TEXT text
설치가 완료 되었을 때 설치 페이지 상단에 출력할 문자열을 설정합니다. ( MUI_U(UN)FINISHPAGE_NOAUTOCLOSE 가 설정되지 않으면 출력되지 않습니다).

MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT text
설치가 완료 되었을 때 설치 페이지 상단에 출력할 하위문자열을 설정합니다. ( MUI_U(UN)FINISHPAGE_NOAUTOCLOSE 가 설정되지 않으면 출력되지 않습니다).

MUI_INSTFILESPAGE_ABORTHEADER_TEXT text
설치가 중단 되었을 때 설치 페이지 상단에 출력할 문자열을 설정합니다.

MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT text
설치가 중단 되었을 때 설치 페이지 상단에 출력할 하위문자열을 설정합니다.

종료 페이지 설정

MUI_FINISHPAGE_TITLE title
페이지 상단에 출력할 제목.

MUI_FINISHPAGE_TITLE_3LINES
제목 영역에 여백을 줍니다.

MUI_FINISHPAGE_TEXT text
페이지에 출력할 문자열을 설정합니다. 줄을 바꾸려면 \r\n 을 사용하세요.

MUI_FINISHPAGE_TEXT_LARGE
문자열 영역의 여백을 줍니다. (만약 체크박스를 사용할때).

MUI_FINISHPAGE_BUTTON text
종료 버튼 문자열을 설정합니다.

MUI_FINISHPAGE_TEXT_REBOOT text
시스템 재부트를 위해 종료 페이지에 출력할 문자열을 설정합니다. 줄을 바꾸려면 \r\n 을 사용하세요.

MUI_FINISHPAGE_TEXT_REBOOTNOW text
'지금 재부팅' 옵션 버튼의 문자열을 바꿉니다.

MUI_FINISHPAGE_TEXT_REBOOTLATER text
'나중에 리부팅' 옵션 버튼에 출력할 문자열을 바꿉니다.

MUI_FINISHPAGE_RUN exe_file
체크박스를 이용하여 사용자가 실행 할 프로그램을 선택합니다. 파일 이름이 공백을 포함할 때 따옴표로 묶을 필요가 없습니다.

MUI_FINISHPAGE_RUN_TEXT text
'프로그램 실행' 체크박스에 표시할 문자열을 설정합니다.

MUI_FINISHPAGE_RUN_PARAMETERS parameters
실행할 프로그램의 매개변수를 설정합니다. 값안에서 "는 반드시 $\" 로 사용해야 하는 것을 잊지 마세요.

MUI_FINISHPAGE_RUN_NOTCHECKED
'프로그램 실행' 체크박스를 기본값으로 비활성화 합니다.

MUI_FINISHPAGE_RUN_FUNCTION function_name
프로그램 실행 대신 함수를 호출합니다 (MUI_FINISHPAGE_RUN 매개변수 없이 선언). 여러 프로그램을 실행하거나 체크박스 이름을 변경하고 다른 여러가지를 하려면 이 기능을 사용하세요.

MUI_FINISHPAGE_SHOWREADME file/url
체크박스를 사용해서 볼 파일이나 웹사이트를 선택합니다. 파일이름이 공백을 포함할 때 따옴표로 묶을 필요가 없습니다.

MUI_FINISHPAGE_SHOWREADME_TEXT text
'Show ReadMe' 체크박스에 표시할 문자열을 설정합니다.

MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
'Show ReadMe' 체크박스를 기본으로 비활성화 합니다.

MUI_FINISHPAGE_SHOWREADME_FUNCTION function_name
파일을 보는 대신에 함수를 호출합니다 (MUI_FINISHPAGE_SHOWREADME 를 매개변수 없이 선언). 여러 파일을 보거나 체크박스 이름을 변경시키고 다른 여러가지를 하려면 이 기능을 사용하세요.

MUI_FINISHPAGE_LINK link_text
파일이나 웹사이트를 보기위해 클릭할 링크에 표시될 문자열을 설정합니다.

MUI_FINISHPAGE_LINK_LOCATION file/url
링크를 사용해서 볼 파일이나 웹사이트를 선택합니다. 파일이름이 공백을 포함할 때 따옴표로 묶을 필요가 없습니다.

MUI_FINISHPAGE_LINK_COLOR (색상: RRGGBB 16진수)
종료 페이지에 출력할 링크의 문자열 색상을 설정합니다.
기본값: 000080

MUI_FINISHPAGE_NOREBOOTSUPPORT
사용자가 시스템을 리부트 하는 기능을 비활성화합니다. 만약 /REBOOTOK 플래그나 SetRebbotFlag 를 사용하지 않는다면 약간의 공간 절약을 위해 이 옵션을 선언하세요.

언인스톨 확인 페이지 설정

MUI_UNCONFIRMPAGE_TEXT_TOP text
페이지 상단에 출력할 문자열.

MUI_UNCONFIRMPAGE_TEXT_LOCATION text
언인스톨 위치 문자열 상자 다음에 출력할 문자열을 설정합니다.

고급 페이지 설정

Modern UI 페이지의 페이지 함수에 사용자 정의 코드를 추가할 수 있습니다. 더 많은 정보를 보려면...

4. 사용자 함수

Modern UI에의해 추가된 함수에 자신만의 코드를 추가하려면 (예. the .onGUIInit 함수와 페이지 함수들), 함수를 만들고 Modern UI 함수가 만든 함수를 호출하게 합니다.

더 많은 정보...

5. 언어 파일

Modern UI 언어 파일을 추가합니다.

!insertmacro MUI_LANGUAGE "English"

Modern UI 언어파일은 NLF 언어파일을 불러오기 때문에 LoadLanguageFile 명령을 사용하면 안됩니다.

언어 선택 대화상자

언어 선택 대화상자를 출력하려면 아래를 참조하세요 MultiLanguage.nsi 예), MUI_LANGDLL_DISPLAY 매크로를 .onInit 함수에 추가합니다:

Function .onInit

 

  !insertmacro MUI_LANGDLL_DISPLAY

 

FunctionEnd

또한 언인스톨러에 사용하려면 un.onInit 에 사용합니다.

언어 선택 대화상자

사용자의 기호를 기억하기위해 레지스트리 키를 선언할 수 있습니다.
Note: 이러한 설정은 설치페이지 매크로를 추가하기 전에 선언해야합니다.

MUI_LANGDLL_REGISTRY_ROOT root
MUI_LANGDLL_REGISTRY_KEY
key
MUI_LANGDLL_REGISTRY_VALUENAME
value_name
언어를 저장할 레지스트리 키를 설정합니다. 사용자의 기호가 저장됩니다. 또한, 언인스톨러에서 올바른 언어를 출력하기위해 사용할 수 있습니다. 언인스톨러에서 이 키를 삭제하는 것을 잊으면 안됩니다.

언인스톨러의 경우, 저장한 언어 기호를 얻기 위하여 MUI_UNGETLANGUAGE 매크로를 un.onInit 에 삽입합니다:

Function un.onInit

 

  !insertmacro MUI_UNGETLANGUAGE

 

FunctionEnd

언어 선택 대화상자 설정

언어 선택 대화상자를 조절하려면 MUI_LANGDLL_DISPLAY 매크를 추가하기 전에 선언해야합니다.

MUI_LANGDLL_WINDOWTITLE text
언어 선택 대화상자에 출력할 윈도 제목.

MUI_LANGDLL_INFO text
언어 선택 대화상자에 출력할 문자열을 설정합니다.

MUI_LANGDLL_ALWAYSSHOW
레지스트리에 언어가 저장되어 있어도 무조건 언어선택 대화상자를 출력합니다. 레지스트리에 저장된 언어가 기본값으로 선택됩니다.

6. 예약 파일

만약 솔리드 압축을 사용한다면 (BZIP2와 LZMA에서는 기본값으로 솔리드 압축을 사용), 인스톨러를 더욱 빠르게하기 때문에 데이터영역에서 다른 파일들보다 앞서 위치한 함수들,(init 함수 또는 페이지 함수들) 에서 풀릴파일을 지정하는 것은 중요합니다.

init 함수 또는 페이지가 함수가 섹션 또는 함수의 File 명령보다 위에 있다면 섹션 또는 함수에 이 매크로를 추가하세요.

ReserveFile "ioFile.ini" ;Your own InstallOptions INI files

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;InstallOptions plug-in

!insertmacro MUI_RESERVEFILE_LANGDLL ;Language selection dialog

7. 자신만의 섹션과 함수

인스톨러 섹션과 함수를 추가할 수 있습니다. 자세한 정보는 NSIS 사용자 설명서를 참조하세요.

위에서 언급했던 시작메뉴 단축아이콘 생성과 언어 선택에 대한 코드와 함수들에 대한 정보.

8. 섹션 설명

컴포넌트 페이지에서 사용자가 마우스를 섹션 위에 올려놓을 때 출력하는 설명합니다. 설명을 사용하지 않으려면 MUI_COMPONENTSPAGE_NODESC 인터페이스 설정을 선언하세요.

섹션에 대한 설명을 설정하려면 Section 명령에서 이름과 함께 섹션 숫자를 포함하는 매개변수를 추가로 선언해야합니다..

Section "Section Name 1" Section1

   ...

SectionEnd

설명을 설정하려면 아래 매크로를 사용하세요:

LangString DESC_Section1 ${LANG_ENGLISH} "Description of section 1."

LangString DESC_Section2 ${LANG_ENGLISH} "Description of section 2."

 

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN

  !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)

  !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)

!insertmacro MUI_FUNCTION_DESCRIPTION_END

언인스톨러의 경우, MUI_UNFUNCTION_DESCRIPTION_BEGIN 과 MUI_UNFUNCTIONS_DESCRIPTION_END 매크로를 사용하세요.

사용자 페이지

인스톨러에 사용자 페이지를 추가하려면 페이지 매크로 사이에 자신만의 페이지 명령을 추가합니다.

!insertmacro MUI_PAGE_WELCOME

Page custom FunctionName ; 사용자페이지

!insertmacro MUI_PAGE_COMPONENTS

 

;Uninstaller

!insertmacro MUI_UNPAGE_CONFIRM

UninstPage custom un.FunctionName ;사용자 페이지

!insertmacro MUI_UNPAGE_INSTFILES

사용자 페이지에서 InstallOptions 사용

INI 파일을 사용하여 사용자페이지를 출력하는 플러그인입니다.

이 문서를 참조하세요 InstallOptions 문서 .

처음, MUI_INSTALLOPTIONS_EXTRACT 매크로를 사용하여 .onInit 함수에서 InstallOptions INI 파일을 풀어야합니다 (언인스톨러는 un.onInit) :

Function .onInit

  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioFile.ini"

FunctionEnd

INI 파일이 다른 디렉토리에 위치한다면 MUI_INSTALLOPTIONS_EXTRACT_AS를 사용하세요. 두번째 매개변수는 임시 플러그인 디렉토리에 대한 파일이름입니다. 다른 InstallOptions 매크로에 대한 매개변수 파일이름을 사용합니다.

Function .onInit

  !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "..\ioFile.ini" "ioFile.ini"

FunctionEnd

MUI_INSTALLOPTIONS_DISPLAY 매크로를 사용하여 Page 또는 UninstPage 명령 사이에 선언한 함수에서 Install Options 를 호출할 수 있습니다. 이 페이지의 헤더에 출력할 문자열을 설정하려면 MUI_HEADER_TEXT 를 사용하세요:

LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Install Options Page Title"

LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "A subtitle"

 

Function FunctionName ; Page 명령에서 선언한 함수 이름

  !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"

  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioFile.ini"

FunctionEnd

사용자 글꼴과 색상을 사용하기위한 initDialog 와 show 함수 또한 사용가능합니다:

Var HWND

Var DLGITEM

Var FONT

 

LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Install Options Page Title"

LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "A subtitle"

 

Function FunctionName ; Page 명령에서 선언한 함수

 

  !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"

 

  !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ioFile.ini"

  Pop $HWND ;HWND of dialog

   

  GetDlgItem $DLGITEM $HWND 1200 ;1200 + Field number - 1

   

  ;$DLGITEM contains the HWND of the first field

  CreateFont $FONT "Tahoma" 10 700

  SendMessage $DLGITEM ${WM_SETFONT} $FONT 0

       

  !insertmacro MUI_INSTALLOPTIONS_SHOW

 

FunctionEnd

InstallOptions의 반환 값이 필요하면 (성공,뒤로,취소,에러등), MUI_INSTALLOPTIONS_DISPLAY_RETURN 또는 MUI_INSTALLOPTIONS_SHOW_RETURN 매크로를 사용하세요. 반환값은 스택에 추가되고 Pop 명령을 사용해서 얻을 수 있습니다.

INI 파일 값에 읽거나 쓰려면 아래와 같은 매크로를 사용하세요:

!insertmacro MUI_INSTALLOPTIONS_READ $VAR "ioFile.ini" "Field #" "Name"

!insertmacro MUI_INSTALLOPTIONS_WRITE "ioFile.ini" "Field #" "Name" "Value"

, MUI_INSTALLOPTIONS_READ 매크로를 사용해서 사용자 입력을 얻을 수 있습니다:

!insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioFile.ini" "Field 1" "State"

사용자 입력 확인등 InstallOptions 에 관한 더 자세한 정보는 아래 문서를 참조하세요 InstallOptions 문서.

표준 대화상자 조절

대화상자안의 구성요소를 변경하려면 조절된 UI 리소스 파일을 사용합니다 ( 인터페이스 환경설정 참조). 리소스 해커 와 같은 툴을 사용하여 원본 파일을 자신만의 파일로 변경할 수 있습니다 (Contrib\UIs 폴더).

수정된 대화상자 111를 가진 사용자 UI 리소스 파일을 사용해서(MUI_UI 설정) 인스톨러가 시작되고 출력되는 스플래쉬 화면(인스톨러 확인, 데이터 추출) 에 출력되는 문자열 'Please wait while Setup is loading...' 을 변경할 수 있습니다.
'Verifying installer' 와 'Unpacking data' 문자열은 NSIS exehead 의 언어 헤더파일에 선언되어 있습니다 (Source\exehead\lang.h). 이것들을 변경하려면 이 파일을 수정하고 NSIS를 재컴파일해야합니다.

환영/종료 대화상자를 변경하려면 사용자 페이지 함수에서 INI파일을 작성하거나 MUI_SPECIALINI 설정을 이용하는 사용자 INI 파일을 사용합니다.

Modern UI 함수 조절

Modern UI에 의해 추가된 함수들에 사용자 코드를 추가하려면 .onGUIInit 함수와 페이지 함수와 같이 자신만의 함수를 만들고 Modern UI 함수가 이 함수를 호출하게 합니다. 함수의 이름을 선언하려면 define 명령을 사용하세요.

:

!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit

 

Function myGUIInit

  ...your own code...

FunctionEnd

범용 사용자 함수

언어 매크로를 추가하기 전에 추가해야 합니다.

MUI_CUSTOMFUNCTION_GUIINIT function
MUI_CUSTOMFUNCTION_UNGUIINIT
function
MUI_CUSTOMFUNCTION_ABORT
function
MUI_CUSTOMFUNCTION_UNABORT function

페이지 사용자 함수

페이지 매크로를 추가하기 전에 선언해야합니다.

MUI_PAGE_CUSTOMFUNCTION_PRE function
MUI_PAGE_CUSTOMFUNCTION_SHOW
function
MUI_PAGE_CUSTOMFUNCTION_LEAVE function

알림:

  • 시작메뉴 페이지는 Show 함수가 없습니다
  • 환영/종료 페이지에 앞서 함수에서 이들 페이지의 INstallOptions INI 파일을 작성 할 수 있습니다 (ioSpecial.ini)
  • 환영/종료 페이지의 Show 함수에서, $MUI_HWND 는 내부 대화상자의 HWND를 포함합니다

환영/종료 페이지 사용자 함수

하나의 환영 또는 종료 페이지에 앞서 선언해야합니다.

MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT function

페이지를 위해 작성된 InstallOptions INI 파일에 앞서 이러한 Init 함수가 호출됩니다. 즉, 페이지 설정에 사용되는 많은 변수 초기화에 사용할 수 있습니다.

예제

기초: Basic.nsi
환영/종료 페이지: WelcomeFinish.nsi
복수 언어: MultiLanguage.nsi
헤더 이미지: HeaderBitmap.nsi
사용자 페이지: InstallOptions.nsi
시작 메뉴 폴더 페이지: StartMenu.nsi

버전 정보

  • 1.72 - November 27, 2004
    • Fixed state of Finish page Cancel button when both an installer and uninstaller page is included

완전한 버전 정보

제작자

Made by Joost Verburg.
Icons designed by Nikos Adamamas, aka adni18.
Thanks to Amir Szekely, aka KiCHiK, for his work on NSIS to make this possible.
초 간단 극악 음독 번역 v0.1 - Hell Master, jgh0721@nate.com

도움말

질문은 이곳에 올려주세요 NSIS 포럼.

라이센스

The zlib/libpng license applies to the Modern UI.

라이센스 용어

Copyright © 2002-2005 Joost Verburg

 

This software is provided 'as-is', without any express or implied

warranty. In no event will the authors be held liable for any damages

arising from the use of this software.

 

Permission is granted to anyone to use this software for any purpose,

including commercial applications, and to alter it and redistribute

it freely, subject to the following restrictions:

 

1. The origin of this software must not be misrepresented;

   you must not claim that you wrote the original software.

   If you use this software in a product, an acknowledgment in the

   product documentation would be appreciated but is not required.

2. Altered versions must be plainly marked as such,

   and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any distribution.

©2002-2005 Joost 

[출처] NSIS_MUI_reference|작성자 후니

AND

출처: http://nsis.sourceforge.net/How_can_I_let_the_compiled_script_depend_on_something_dynamic


How can I let the compiled script depend on something dynamic

From NSIS Wiki

Compile your script with /DNAME=value or /X"nsis command" passed on to makensis.exe as command line arguments. The /D switch of the compiler will define NAME as value in the script. The /X switch will add "nsis command" to the top of the script.

Example:

In the compiling script:

ExecWait "makensis.exe /DVERSION=1.2 myscript.nsi"

In the compiled dynamic script:

OutFile myprog${VERSION}.exe

Note - These flags *must* be specified on a makensis command line before you specify the script name. If you have "makensis.exe myscript.nsi /DVERSION=1.2 " then VERSION will not be set.

AND