This commit was generated by cvs2svn to compensate for changes in r2,

which included commits to RCS files with non-trunk default branches.


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@625 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-08-02 10:01:35 +00:00
parent 9b3b220a13
commit 3e9e73ec59
177 changed files with 37677 additions and 0 deletions

164
Examples/WinMessages.NSH Normal file
View file

@ -0,0 +1,164 @@
; KiCHiK put together this list of WM_ messages.
!define WM_NULL 0x0
!define WM_CREATE 0x1
!define WM_DESTROY 0x2
!define WM_MOVE 0x3
!define WM_SIZE 0x5
!define WM_SETFOCUS 0x7
!define WM_KILLFOCUS 0x8
!define WM_ENABLE 0xA
!define WM_SETREDRAW 0xB
!define WM_SETTEXT 0xC
!define WM_GETTEXT 0xD
!define WM_GETTEXTLENGTH 0xE
!define WM_PAINT 0xF
!define WM_CLOSE 0x10
!define WM_QUERYENDSESSION 0x11
!define WM_QUIT 0x12
!define WM_QUERYOPEN 0x13
!define WM_ERASEBKGND 0x14
!define WM_SYSCOLORCHANGE 0x15
!define WM_ENDSESSION 0x16
!define WM_SHOWWINDOW 0x18
!define WM_WININICHANGE 0x1A
!define WM_DEVMODECHANGE 0x1B
!define WM_ACTIVATEAPP 0x1C
!define WM_FONTCHANGE 0x1D
!define WM_TIMECHANGE 0x1E
!define WM_CANCELMODE 0x1F
!define WM_SETCURSOR 0x20
!define WM_MOUSEACTIVATE 0x21
!define WM_CHILDACTIVATE 0x22
!define WM_QUEUESYNC 0x23
!define WM_GETMINMAXINFO 0x24
!define WM_PAINTICON 0x26
!define WM_ICONERASEBKGND 0x27
!define WM_NEXTDLGCTL 0x28
!define WM_SPOOLERSTATUS 0x2A
!define WM_DRAWITEM 0x2B
!define WM_MEASUREITEM 0x2C
!define WM_DELETEITEM 0x2D
!define WM_VKEYTOITEM 0x2E
!define WM_CHARTOITEM 0x2F
!define WM_SETFONT 0x30
!define WM_GETFONT 0x31
!define WM_SETHOTKEY 0x32
!define WM_GETHOTKEY 0x33
!define WM_QUERYDRAGICON 0x37
!define WM_COMPAREITEM 0x39
!define WM_COMPACTING 0x41
!define WM_WINDOWPOSCHANGING 0x46
!define WM_WINDOWPOSCHANGED 0x47
!define WM_POWER 0x48
!define WM_COPYDATA 0x4A
!define WM_CANCELJOURNAL 0x4B
!define WM_NCCREATE 0x81
!define WM_NCDESTROY 0x82
!define WM_NCCALCSIZE 0x83
!define WM_NCHITTEST 0x84
!define WM_NCPAINT 0x85
!define WM_NCACTIVATE 0x86
!define WM_GETDLGCODE 0x87
!define WM_NCMOUSEMOVE 0xA0
!define WM_NCLBUTTONDOWN 0xA1
!define WM_NCLBUTTONUP 0xA2
!define WM_NCLBUTTONDBLCLK 0xA3
!define WM_NCRBUTTONDOWN 0xA4
!define WM_NCRBUTTONUP 0xA5
!define WM_NCRBUTTONDBLCLK 0xA6
!define WM_NCMBUTTONDOWN 0xA7
!define WM_NCMBUTTONUP 0xA8
!define WM_NCMBUTTONDBLCLK 0xA9
!define WM_KEYFIRST 0x100
!define WM_KEYDOWN 0x100
!define WM_KEYUP 0x101
!define WM_CHAR 0x102
!define WM_DEADCHAR 0x103
!define WM_SYSKEYDOWN 0x104
!define WM_SYSKEYUP 0x105
!define WM_SYSCHAR 0x106
!define WM_SYSDEADCHAR 0x107
!define WM_KEYLAST 0x108
!define WM_INITDIALOG 0x110
!define WM_COMMAND 0x111
!define WM_SYSCOMMAND 0x112
!define WM_TIMER 0x113
!define WM_HSCROLL 0x114
!define WM_VSCROLL 0x115
!define WM_INITMENU 0x116
!define WM_INITMENUPOPUP 0x117
!define WM_MENUSELECT 0x11F
!define WM_MENUCHAR 0x120
!define WM_ENTERIDLE 0x121
!define WM_CTLCOLORMSGBOX 0x132
!define WM_CTLCOLOREDIT 0x133
!define WM_CTLCOLORLISTBOX 0x134
!define WM_CTLCOLORBTN 0x135
!define WM_CTLCOLORDLG 0x136
!define WM_CTLCOLORSCROLLBAR 0x137
!define WM_CTLCOLORSTATIC 0x138
!define WM_MOUSEFIRST 0x200
!define WM_MOUSEMOVE 0x200
!define WM_LBUTTONDOWN 0x201
!define WM_LBUTTONUP 0x202
!define WM_LBUTTONDBLCLK 0x203
!define WM_RBUTTONDOWN 0x204
!define WM_RBUTTONUP 0x205
!define WM_RBUTTONDBLCLK 0x206
!define WM_MBUTTONDOWN 0x207
!define WM_MBUTTONUP 0x208
!define WM_MBUTTONDBLCLK 0x209
!define WM_MOUSELAST 0x209
!define WM_PARENTNOTIFY 0x210
!define WM_ENTERMENULOOP 0x211
!define WM_EXITMENULOOP 0x212
!define WM_MDICREATE 0x220
!define WM_MDIDESTROY 0x221
!define WM_MDIACTIVATE 0x222
!define WM_MDIRESTORE 0x223
!define WM_MDINEXT 0x224
!define WM_MDIMAXIMIZE 0x225
!define WM_MDITILE 0x226
!define WM_MDICASCADE 0x227
!define WM_MDIICONARRANGE 0x228
!define WM_MDIGETACTIVE 0x229
!define WM_MDISETMENU 0x230
!define WM_DROPFILES 0x233
!define WM_MDIREFRESHMENU 0x234
!define WM_CUT 0x300
!define WM_COPY 0x301
!define WM_PASTE 0x302
!define WM_CLEAR 0x303
!define WM_UNDO 0x304
!define WM_RENDERFORMAT 0x305
!define WM_RENDERALLFORMATS 0x306
!define WM_DESTROYCLIPBOARD 0x307
!define WM_DRAWCLIPBOARD 0x308
!define WM_PAINTCLIPBOARD 0x309
!define WM_VSCROLLCLIPBOARD 0x30A
!define WM_SIZECLIPBOARD 0x30B
!define WM_ASKCBFORMATNAME 0x30C
!define WM_CHANGECBCHAIN 0x30D
!define WM_HSCROLLCLIPBOARD 0x30E
!define WM_QUERYNEWPALETTE 0x30F
!define WM_PALETTEISCHANGING 0x310
!define WM_PALETTECHANGED 0x311
!define WM_HOTKEY 0x312
!define WM_PENWINFIRST 0x380
!define WM_PENWINLAST 0x38F
!define WM_USER 0x400
!define WM_DDE_FIRST 0x3E0
!define WM_CONVERTREQUESTEX 0x108
!define WM_IME_STARTCOMPOSITION 0x10D
!define WM_IME_ENDCOMPOSITION 0x10E
!define WM_IME_COMPOSITION 0x10F
!define WM_IME_KEYLAST 0x10F
!define WM_IME_SETCONTEXT 0x281
!define WM_IME_NOTIFY 0x282
!define WM_IME_CONTROL 0x283
!define WM_IME_COMPOSITIONFULL 0x284
!define WM_IME_SELECT 0x285
!define WM_IME_CHAR 0x286
!define WM_IME_KEYDOWN 0x290
!define WM_IME_KEYUP 0x291

239
Examples/bigtest.nsi Normal file
View file

@ -0,0 +1,239 @@
; bigtest.nsi
;
; This script attempts to test most of the functionality of NSIS.
;
!ifdef HAVE_UPX
!packhdr tmp.dat "upx\upx -9 tmp.dat"
!endif
!ifdef NOCOMPRESS
SetCompress off
!endif
SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
BGGradient 000000 800000 FFFFFF
InstallColors FF8080 000030
Name "BigNSISTest"
Caption "NSIS Big Test"
Icon "..\contrib\Icons\normal-install.ico"
OutFile "bigtest.exe"
LicenseText "make sure this license text is all there (it's about 28k last I checked). The last line is a simple '}'."
LicenseData "..\source\exehead\main.c"
InstallDir "$PROGRAMFILES\NSISCrap\BigNSISTest"
InstallDirRegKey HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir"
DirText "Choose a directory to install in to:"
; uninstall stuff
UninstallText "This will uninstall example2. Hit next to continue."
UninstallIcon "..\contrib\Icons\normal-uninstall.ico"
ComponentText "This will install the test on your computer. Select which optional things you want installed."
CheckBitmap ..\contrib\Icons\checksX.bmp
!ifndef NOINSTTYPES ; only if not defined
InstType "Most"
InstType "Full"
InstType "More"
InstType "Base"
;InstType /NOCUSTOM
;InstType /COMPONENTSONLYONCUSTOM
!endif
AutoCloseWindow false
ShowInstDetails show
Section "" ; empty string makes it hidden, so would starting with -
; write reg crap
StrCpy $1 "POOOOOOOOOOOP"
DetailPrint "I like to f*ck sheep $1"
WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "Install_Dir" "$INSTDIR"
; write uninstall strings
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "DisplayName" "BigNSISTest (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "UninstallString" '"$INSTDIR\bt-uninst.exe"'
#File /oname=poop.exe makensisw.exe
SetOutPath $INSTDIR
File /a "..\source\exehead\bin2h.exe"
CreateDirectory "$INSTDIR\shiz\crap" ; 2 recursively create a directory for fun.
WriteUninstaller "bt-uninst.exe"
Nop ; for fun
SectionEnd
Section "TempTest"
SectionIn 1 2 3
Start: MessageBox MB_OK "Start:"
MessageBox MB_YESNO "Goto Poop" IDYES Poop
MessageBox MB_OK "Right before Poop:"
Poop: MessageBox MB_OK "Poop:"
MessageBox MB_OK "Right after Poop:"
MessageBox MB_YESNO "Goto Start:?" IDYES Start
SectionEnd
Function poopTest
ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
StrCmp $1 $8 NoFailedMsg
MessageBox MB_OK "WriteINIStr failed"
NoFailedMsg: FunctionEnd
SubSection /e SubSection1
Section "Test Registry/INI functions"
SectionIn 1 4 3
WriteRegStr HKLM SOFTWARE\NSISCrap\BigNSISTest "StrTest_INSTDIR" "$INSTDIR"
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0xDEADBEEF" 0xdeadbeef
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_123456" 123456
WriteRegDword HKLM SOFTWARE\NSISCrap\BigNSISTest "DwordTest_0123" 0123
WriteRegBin HKLM SOFTWARE\NSISCrap\BigNSISTest "BinTest_deadbeef01f00dbeef" "DEADBEEF01F00DBEEF"
StrCpy $8 "$SYSDIR\Poop"
WriteINIStr "$INSTDIR\test.ini" "MySection" "Value1" $8
WriteINIStr "$INSTDIR\test.ini" "MySectionShit" "Value1" $8
WriteINIStr "$INSTDIR\test.ini" "MySectionShit" "Value2" $8
WriteINIStr "$INSTDIR\test.ini" "POOPon" "Value1" $8
Call poopTest
DeleteINIStr "$INSTDIR\test.ini" "POOPon" "Value1"
DeleteINISec "$INSTDIR\test.ini" "MySectionShit"
ReadINIStr $1 "$INSTDIR\test.ini" "MySectionShit" "Value1"
StrCmp $1 "" INIDelSuccess
MessageBox MB_OK "DeleteINISec failed"
INIDelSuccess:
ClearErrors
ReadRegStr $1 HKCR "software\microsoft" shit
IfErrors 0 NoError
MessageBox MB_OK "could not read from HKCR\software\microsoft\shit"
Goto ErrorYay
NoError:
MessageBox MB_OK "read '$1' from HKCR\software\microsoft\shit"
ErrorYay:
SectionEnd
Function "CSCTest"
CreateDirectory "$SMPROGRAMS\Big NSIS Test"
SetOutPath $INSTDIR ; for working directory
CreateShortCut "$SMPROGRAMS\Big NSIS Test\Uninstall BIG NSIS Test.lnk" "$INSTDIR\bt-uninst.exe" ; use defaults for parameters, icon, etc.
; this one will use notepad's icon, start it minimized, and give it a hotkey (of Ctrl+Shift+Q)
CreateShortCut "$SMPROGRAMS\Big NSIS Test\bin2h.exe.lnk" "$INSTDIR\bin2h.exe" "" "$WINDIR\notepad.exe" 0 SW_SHOWMINIMIZED CONTROL|SHIFT|Q
CreateShortCut "$SMPROGRAMS\Big NSIS Test\TheDir.lnk" "$INSTDIR\" "" "" 0 SW_SHOWMAXIMIZED CONTROL|SHIFT|Z
FunctionEnd
Section "Test CreateShortCut"
SectionIn 1 2 3
Call CSCTest
SectionEnd
SubSection Sub2
Function myfunc
StrCpy $2 "poop=$1"
MessageBox MB_OK "myfunc: $2"
FunctionEnd
Section "Test Branching"
BeginTestSection:
SectionIn 1 2 3
SetOutPath $INSTDIR
IfFileExists "$INSTDIR\bin2h.c" 0 BranchTest69
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite $INSTDIR\bin2h.c?" IDNO NoOverwrite ; skipped if file doesn't exist
BranchTest69:
SetOverwrite ifnewer ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
NoOverwrite:
File "..\source\exehead\bin2h.c" ; skipped if answered no
SetOverwrite try ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to skip the rest of this section?" IDYES EndTestBranch
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to go back to the beginning of this section?" IDYES BeginTestSection
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to hide the installer and wait five seconds?" IDNO NoHide
HideWindow
Sleep 5000
BringToFront
NoHide:
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to call the function 5 times?" IDNO NoRecurse
StrCpy $1 "x"
LoopPoop:
Call myfunc
StrCpy $1 "x$1"
StrCmp $1 "xxxxxx" 0 LoopPoop
NoRecurse:
EndTestBranch:
SectionEnd
SubSectionEnd
Section "Test CopyFiles"
SectionIn 1 2 3
SetOutPath $INSTDIR\cpdest
CopyFiles "$WINDIR\*.ini" "$INSTDIR\cpdest" 0
SectionEnd
SubSectionEnd
Section "Test Exec functions" CRAPIDX
SectionIn 1 2 3
SearchPath $1 notepad.exe
MessageBox MB_OK "notepad.exe=$1"
Exec '"$1"'
ExecShell "open" '"$INSTDIR"'
Sleep 500
BringToFront
SectionEnd
Section "Test ActiveX control registration"
SectionIn 2
UnRegDLL "$SYSDIR\spin32.ocx"
Sleep 1000
RegDLL "$SYSDIR\spin32.ocx"
Sleep 1000
SectionEnd
; special uninstall section.
Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest"
DeleteRegKey HKLM "SOFTWARE\NSISCrap\BigNSISTest"
Delete "$INSTDIR\bin2h.exe"
Delete "$INSTDIR\bin2h.c"
Delete "$INSTDIR\bt-uninst.exe"
Delete "$INSTDIR\test.ini"
Delete "$SMPROGRAMS\Big NSIS Test\*.*"
RMDir "$SMPROGRAMS\BiG NSIS Test"
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to remove the directory $INSTDIR\cpdest?" IDNO NoDelete
Delete "$INSTDIR\cpdest\*.*"
RMDir "$INSTDIR\cpdest" ; skipped if no
NoDelete:
RMDir "$INSTDIR\shiz\crap"
RMDir "$INSTDIR\shiz"
RMDir "$INSTDIR"
IfFileExists "$INSTDIR" 0 NoErrorMsg
MessageBox MB_OK "Note: $INSTDIR could not be removed!" IDOK 0 ; skipped if file doesn't exist
NoErrorMsg:
SectionEnd
; eof
Function .onSelChange
SectionGetText ${CRAPIDX} $0
StrCmp $0 "" e
SectionSetText ${CRAPIDX} ""
Goto e2
e:
SectionSetText ${CRAPIDX} "Doop"
e2:
FunctionEnd

104
Examples/branding.nsh Normal file
View file

@ -0,0 +1,104 @@
; Written by Amir Szekely 24th July 2002
; Please see gfx.nsi for example of usage
!verbose 3
; If we haven't included this as install macros yet
!ifndef BI_MACROS_USED
; If this isn't supposed to be uninstall macros
!ifndef BI_UNINSTALL
!define BI_MACROS_USED
; Undefine BI_FUNC if already defined by uninstaller macros
!ifdef BI_FUNC
!undef BI_FUNC
!endif
; Define BI_FUNC
!define BI_FUNC "BIChange"
; If BI_VAR or BI_TEMPFILE was already defined undefine it so BI_INIT can redefine it
!ifdef BI_VAR
!undef BI_VAR
!endif
!ifdef BI_TEMPFILE
!undef BI_TEMPFILE
!endif
; If macros aren't defined yet, define them
!ifndef UBI_MACROS_USED
!define BI_OK
!endif
; Done
!endif
!endif
; If we haven't included this as uninstall macros yet
!ifndef UBI_MACROS_USED
; If this is supposed to be uninstall macros
!ifdef BI_UNINSTALL
!define UBI_MACROS_USED
; Undefine BI_FUNC if already defined by installer macros
!ifdef BI_FUNC
!undef BI_FUNC
!endif
; Define BI_FUNC
!define BI_FUNC "un.BIChange"
; If BI_VAR or BI_TEMPFILE was already defined undefine it so BI_INIT can redefine it
!ifdef BI_VAR
!undef BI_VAR
!endif
!ifdef BI_TEMPFILE
!undef BI_TEMPFILE
!endif
; If macros aren't defined yet, define them
!ifndef BI_MACROS_USED
!define BI_OK
!endif
; Done
!endif
!endif
!ifdef BI_OK
!macro BI_INIT VAR
!define BI_VAR ${VAR}
StrCpy ${BI_VAR} 0
!macroend
!macro BI_NEXT
IntOp ${BI_VAR} ${BI_VAR} + 1
Call ${BI_FUNC}
!macroend
!macro BI_PREV
IntOp ${BI_VAR} ${BI_VAR} - 1
Call ${BI_FUNC}
!macroend
!macro BI_LIST
Function ${BI_FUNC}
Push $0
Push $1
StrCpy $0 0
GetTempFileName $1
!macroend
!macro BI_LIST_ADD IMAGE PARMS
IntOp $0 $0 + 1
StrCmp ${BI_VAR} $0 0 +4
File /oname=$1 "${IMAGE}"
SetBrandingImage ${PARMS} $1
Goto BI_done
!macroend
!macro BI_LIST_END
BI_done:
Delete $1
Pop $1
Pop $0
FunctionEnd
!macroend
!undef BI_OK
!endif ; ifdef BI_OK
!verbose 4
!echo "Branding macros defined successfully!"

29
Examples/example1.nsi Normal file
View file

@ -0,0 +1,29 @@
; example1.nsi
;
; This script is perhaps one of the simplest NSIs you can make. All of the
; optional settings are left to their default settings. The instalelr simply
; prompts the user asking them where to install, and drops of makensisw.exe
; there.
;
; The name of the installer
Name "Example1"
; The file to write
OutFile "example1.exe"
; The default installation directory
InstallDir $PROGRAMFILES\Example1
; The text to prompt the user to enter a directory
DirText "This will install the very simple example1 on your computer. Choose a directory"
; The stuff to install
Section "ThisNameIsIgnoredSoWhyBother?"
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File ..\makensisw.exe
SectionEnd ; end the section
; eof

67
Examples/example2.nsi Normal file
View file

@ -0,0 +1,67 @@
; example2.nsi
;
; This script is based on example1.nsi, but adds uninstall support
; and (optionally) start menu shortcuts.
;
; It will install notepad.exe into a directory that the user selects,
;
; The name of the installer
Name "Example2"
; The file to write
OutFile "example2.exe"
; The default installation directory
InstallDir $PROGRAMFILES\Example2
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\NSIS_Example2 "Install_Dir"
; The text to prompt the user to enter a directory
ComponentText "This will install the less simple example2 on your computer. Select which optional things you want installed."
; The text to prompt the user to enter a directory
DirText "Choose a directory to install in to:"
; The stuff to install
Section "Example2 (required)"
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File "..\makensisw.exe"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "DisplayName" "NSIS Example2 (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "uninstall.exe"
SectionEnd
; optional section
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\Example2"
CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\Example2\Example2 (notepad).lnk" "$INSTDIR\notepad.exe" "" "$INSTDIR\makensisw.exe" 0
SectionEnd
; uninstall stuff
UninstallText "This will uninstall example2. Hit next to continue."
; special uninstall section.
Section "Uninstall"
; remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2"
DeleteRegKey HKLM SOFTWARE\NSIS_Example2
; remove files
Delete $INSTDIR\makensisw.exe
; MUST REMOVE UNINSTALLER, too
Delete $INSTDIR\uninstall.exe
; remove shortcuts, if any.
Delete "$SMPROGRAMS\Example2\*.*"
; remove directories used.
RMDir "$SMPROGRAMS\Example2"
RMDir "$INSTDIR"
SectionEnd
; eof

614
Examples/functions.htm Normal file
View file

@ -0,0 +1,614 @@
<HTML><HEAD><TITLE>NSIS utility functions</TITLE>
<BODY>
<H1>NSIS utility functions</H1>
<H3>Contents:</H3>
<UL>
<li><a href="#General">General utility</a>
<ul>
<li><a href="#GetParent">GetParent</a>
<li><a href="#TrimNewlines">TrimNewlines</a>
<li><a href="#GetParameters">GetParameters</a>
<li><a href="#StrStr">StrStr</a>
</ul>
<LI><A href="#Versions">System version checking</A>
<UL>
<LI><A href="#GetWindowsVersion">GetWindowsVersion</A>
<LI><A href="#GetIEVersion">GetIEVersion</A>
<LI><A href="#IsFlashInstalled">IsFlashInstalled</A>
</UL>
<LI><A href="#SharedDLL">Shared DLL functions</A>
<UL>
<LI><A href="#un.RemoveSharedDLL">un.RemoveSharedDLL</A>
<LI><A href="#AddSharedDLL">AddSharedDLL</A>
<LI><A href="#UpgradeDLL">UpgradeDLL</A> (macro)
</UL>
<LI><A href="#Winamp">Winamp functions</A>
<UL>
<LI><A href="#GetWinampInstPath">GetWinampInstPath</A>
<LI><A href="#GetWinampVisPath">GetWinampVisPath</A>
<LI><A href="#GetWinampDSPPath">GetWinampDSPPath</A>
<LI><A href="#GetWinampSkinPath">GetWinampSkinPath</A>
<LI><A href="#CloseWinamp">CloseWinamp</A>
</UL>
<LI><A href="#Netscape">Netscape functions</A>
<UL>
<LI><A href="#InstallNetscapePlugin">InstallNetscapePlugin</A>
<LI><A href="#un.RemoveNetscapePlugin">un.RemoveNetscapePlugin</A>
</UL>
</UL>
<hr>
<A name=General>General utility: <PRE>
;<A name=GetParent>------------------------------------------------------------------------------
; GetParent
; input, top of stack (i.e. C:\Program Files\Poop)
; output, top of stack (replaces, with i.e. C:\Program Files)
; modifies no other variables.
;
; Usage:
; Push "C:\Program Files\Directory\Whatever"
; Call GetParent
; Pop $0
; ; at this point $0 will equal "C:\Program Files\Directory"
Function GetParent
Exch $0 ; old $0 is on top of stack
Push $1
Push $2
StrCpy $1 -1
loop:
StrCpy $2 $0 1 $1
StrCmp $2 "" exit
StrCmp $2 "\" exit
IntOp $1 $1 - 1
Goto loop
exit:
StrCpy $0 $0 $1
Pop $2
Pop $1
Exch $0 ; put $0 on top of stack, restore $0 to original value
FunctionEnd
;<A name=TrimNewlines>------------------------------------------------------------------------------
; TrimNewlines
; input, top of stack (i.e. whatever$\r$\n)
; output, top of stack (replaces, with i.e. whatever)
; modifies no other variables.
;
Function TrimNewlines
Exch $0
Push $1
Push $2
StrCpy $1 0
loop:
IntOp $1 $1 - 1
StrCpy $2 $0 1 $1
StrCmp $2 "$\r" loop
StrCmp $2 "$\n" loop
IntOp $1 $1 + 1
StrCpy $0 $0 $1
Pop $2
Pop $1
Exch $0
FunctionEnd
;<A name=GetParameters>------------------------------------------------------------------------------
; GetParameters
; input, none
; output, top of stack (replaces, with i.e. whatever)
; modifies no other variables.
Function GetParameters
Push $0
Push $1
Push $2
StrCpy $0 $CMDLINE 1
StrCpy $1 '"'
StrCpy $2 1
StrCmp $0 '"' loop
StrCpy $1 ' ' ; we're scanning for a space instead of a quote
loop:
StrCpy $0 $CMDLINE 1 $2
StrCmp $0 $1 loop2
StrCmp $0 "" loop2
IntOp $2 $2 + 1
Goto loop
loop2:
IntOp $2 $2 + 1
StrCpy $0 $CMDLINE 1 $2
StrCmp $0 " " loop2
StrCpy $0 $CMDLINE "" $2
Pop $2
Pop $1
Exch $0
FunctionEnd
;<a name=StrStr>------------------------------------------------------------------------------
; StrStr
; input, top of stack = string to search for
; top of stack-1 = string to search in
; output, top of stack (replaces with the portion of the string remaining)
; modifies no other variables.
;
; Usage:
; Push "this is a long ass string"
; Push "ass"
; Call StrStr
; Pop $0
; ($0 at this point is "ass string")
Function StrStr
Exch $1 ; st=haystack,old$1, $1=needle
Exch ; st=old$1,haystack
Exch $2 ; st=old$1,old$2, $2=haystack
Push $3
Push $4
Push $5
StrLen $3 $1
StrCpy $4 0
; $1=needle
; $2=haystack
; $3=len(needle)
; $4=cnt
; $5=tmp
loop:
StrCpy $5 $2 $3 $4
StrCmp $5 $1 done
StrCmp $5 "" done
IntOp $4 $4 + 1
Goto loop
done:
StrCpy $1 $2 "" $4
Pop $5
Pop $4
Pop $3
Pop $2
Exch $1
FunctionEnd
</PRE>
<HR>
<A name=Versions>System version checking: <PRE>
<A name=GetWindowsVersion>;------------------------------------------------------------------------------
; GetWindowsVersion
;
; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
; Returns on top of stack
;
; Windows Version (95, 98, ME, NT x.x, 2000)
; or
; '' (Unknown Windows Version)
;
; Usage:
; Call GetWindowsVersion
; Pop $0
; ; at this point $0 is "NT 4.0" or whatnot
Function GetWindowsVersion
Push $0
Push $9
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $0 "" 0 lbl_winnt
; we are not NT.
ReadRegStr $0 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion VersionNumber
StrCpy $9 $0 1
StrCmp $9 '4' 0 lbl_error
StrCpy $9 $0 3
StrCmp $9 '4.0' lbl_win32_95
StrCmp $9 '4.9' lbl_win32_ME lbl_win32_98
lbl_win32_95:
StrCpy $0 '95'
Goto lbl_done
lbl_win32_98:
StrCpy $0 '98'
Goto lbl_done
lbl_win32_ME:
StrCpy $0 'ME'
Goto lbl_done
lbl_winnt:
StrCpy $9 $0 1
StrCmp $9 '3' lbl_winnt_x
StrCmp $9 '4' lbl_winnt_x
StrCmp $9 '5' lbl_winnt_5 lbl_error
lbl_winnt_x:
StrCpy $0 "NT $0" 6
Goto lbl_done
lbl_winnt_5:
Strcpy $0 '2000'
Goto lbl_done
lbl_error:
Strcpy $0 ''
lbl_done:
Pop $9
Exch $0
FunctionEnd
<A name=GetIEVersion>;------------------------------------------------------------------------------
; GetIEVersion
;
; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
; Returns on top of stack
; 1-6 (Installed IE Version)
; or
; '' (IE is not installed)
;
; Usage:
; Call GetIEVersion
; Pop $0
; ; at this point $0 is "5" or whatnot
Function GetIEVersion
Push $0
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Internet Explorer" "Version"
IfErrors lbl_123 lbl_456
lbl_456: ; ie 4+
Strcpy $0 $0 1
Goto lbl_done
lbl_123: ; older ie version
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Internet Explorer" "IVer"
IfErrors lbl_error
StrCpy $0 $0 3
StrCmp $0 '100' lbl_ie1
StrCmp $0 '101' lbl_ie2
StrCmp $0 '102' lbl_ie2
StrCpy $0 '3' ; default to ie3 if not 100, 101, or 102.
Goto lbl_done
lbl_ie1:
StrCpy $0 '1'
Goto lbl_done
lbl_ie2:
StrCpy $0 '2'
Goto lbl_done
lbl_error:
StrCpy $0 ''
lbl_done:
Exch $0
FunctionEnd
<A name=IsFlashInstalled>;------------------------------------------------------------------------------
; IsFlashInstalled
;
; By Yazno, http://yazno.tripod.com/powerpimpit/
; Returns on top of stack
; 0 (Flash is not installed)
; or
; 1 (Flash is installed)
;
; Usage:
; Call IsFlashInstalled
; Pop $0
; ; $0 at this point is "1" or "0"
Function IsFlashInstalled
Push $0
ClearErrors
ReadRegStr $0 HKCR "CLSID\{D27CDB6E-AE6D-11cf-96B8-444553540000}" ""
IfErrors lbl_na
StrCpy $0 1
Goto lbl_end
lbl_na:
StrCpy $0 0
lbl_end:
Exch $0
FunctionEnd
</PRE>
<HR>
<A name=SharedDLL>Shared DLL functions:
<PRE><A name="un.RemoveSharedDLL">;------------------------------------------------------------------------------
; un.RemoveSharedDLL
;
; Decrements a shared DLLs reference count, and removes if necessary.
; Use by passing one item on the stack (the full path of the DLL).
; Note: for use in the main installer (not the uninstaller), rename the
; function to RemoveSharedDLL.
;
; Usage:
; Push $SYSDIR\myDll.dll
; Call un.RemoveShareDLL
;
Function un.RemoveSharedDLL
Exch $9
Push $0
ReadRegDword $0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $9
StrCmp $0 "" remove
IntOp $0 $0 - 1
IntCmp $0 0 rk rk uk
rk:
DeleteRegValue HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $9
goto Remove
uk:
WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $9 $0
Goto noremove
remove:
Delete /REBOOTOK $9
noremove:
Pop $0
Pop $9
FunctionEnd
<A name=AddSharedDLL>;------------------------------------------------------------------------------
; AddSharedDLL
;
; Increments a shared DLLs reference count.
; Use by passing one item on the stack (the full path of the DLL).
;
; Usage:
; Push $SYSDIR\myDll.dll
; Call AddSharedDLL
;
Function AddSharedDLL
Exch $9
Push $0
ReadRegDword $0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $9
IntOp $0 $0 + 1
WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $9 $0
Pop $0
Pop $9
FunctionEnd
<A name=UpgradeDLL>;------------------------------------------------------------------------------
; UpgradeDLL (macro)
;
; Updates a DLL (or executable) based on version resource information.
;
; Input: param = input source file.
; top of stack = full path on system to install file to.
;
; Output: none (removes full path from stack)
;
; Usage:
;
; Push "$SYSDIR\atl.dll"
; !insertmacro UpgradeDLL "atl.dll"
;
!macro UpgradeDLL DLL_NAME
Exch $0
Push $1
Push $2
Push $3
Push $4
ClearErrors
GetDLLVersionLocal ${DLL_NAME} $1 $2
GetDLLVersion $0 $3 $4
IfErrors upgrade_${DLL_NAME}
IntCmpU $1 $3 "" noupgrade_${DLL_NAME} upgrade_${DLL_NAME}
IntCmpU $2 $4 noupgrade_${DLL_NAME} noupgrade_${DLL_NAME}
upgrade_${DLL_NAME}:
UnRegDLL $0
File /oname=$0 ${DLL_NAME}
RegDLL $0
noupgrade_${DLL_NAME}:
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
!macroend
</PRE>
<HR>
<A name=Winamp>Winamp functions: <PRE><A name=GetWinampInstPath>;------------------------------------------------------------------------------
; GetWinampInstPath
;
; takes no parameters
; returns with the winamp install directory on the stack (it will be
; an empty string if winamp is not detected).
;
; modifies no other variables
;
; Usage:
; Call GetWinampInstPath
; Pop $0
; MessageBox MB_OK "Winamp installed at: $0"
Function GetWinampInstPath
Push $0
Push $1
Push $2
ReadRegStr $0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"
StrCmp $0 "" fin
StrCpy $1 $0 1 0 ; get firstchar
StrCmp $1 '"' "" getparent
; if first char is ", let's remove "'s first.
StrCpy $0 $0 "" 1
StrCpy $1 0
rqloop:
StrCpy $2 $0 1 $1
StrCmp $2 '"' rqdone
StrCmp $2 "" rqdone
IntOp $1 $1 + 1
Goto rqloop
rqdone:
StrCpy $0 $0 $1
getparent:
; the uninstall string goes to an EXE, let's get the directory.
StrCpy $1 -1
gploop:
StrCpy $2 $0 1 $1
StrCmp $2 "" gpexit
StrCmp $2 "\" gpexit
IntOp $1 $1 - 1
Goto gploop
gpexit:
StrCpy $0 $0 $1
StrCmp $0 "" fin
IfFileExists $0\winamp.exe fin
StrCpy $0 ""
fin:
Pop $2
Pop $1
Exch $0
FunctionEnd
<A name=GetWinampVisPath>;------------------------------------------------------------------------------
; GetWinampVisPath
;
; requires $INSTDIR to point to the Winamp directory.
; sets $OUTDIR with vis plug-in path
;
; modifies no other variables
Function GetWinampVisPath
ReadINIStr $OUTDIR $INSTDIR\winamp.ini Winamp VisDir
StrCmp $OUTDIR "" NoINISetting
IfFileExists $OUTDIR Good
NoINISetting:
StrCpy $OUTDIR $INSTDIR\Plugins
Good:
FunctionEnd
<A name=GetWinampDSPPath>;------------------------------------------------------------------------------
; GetWinampDSPPath
;
; requires $INSTDIR to point to the Winamp directory.
; sets $OUTDIR with dsp plug-in path
;
; modifies no other variables
Function GetWinampDSPPath
ReadINIStr $OUTDIR $INSTDIR\winamp.ini Winamp DSPDir
StrCmp $OUTDIR "" NoINISetting
IfFileExists $OUTDIR Good
NoINISetting:
StrCpy $OUTDIR $INSTDIR\Plugins
Good:
FunctionEnd
<A name=GetWinampSkinPath>;------------------------------------------------------------------------------
; GetWinampSkinPath
;
; requires $INSTDIR to point to the Winamp directory.
; sets $OUTDIR with skin plug-in path
;
; modifies no other variables
Function GetWinampSkinPath
ReadINIStr $OUTDIR $INSTDIR\winamp.ini Winamp SkinDir
StrCmp $OUTDIR "" NoINISetting
IfFileExists $OUTDIR Good
NoINISetting:
StrCpy $OUTDIR $INSTDIR\Skins
Good:
FunctionEnd
<A name=CloseWinamp>;------------------------------------------------------------------------------
; CloseWinamp
;
; Closes all running instances of Winamp 1.x/2.x
;
; modifies no other variables
Function CloseWinamp
Push $0
loop:
FindWindow $0 "Winamp v1.x"
IntCmp $0 0 done
SendMessage $0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
</PRE>
<HR>
<A name=Netscape>Netscape functions: <PRE>
<A name=InstallNetscapePlugin>;------------------------------------------------------------------------------
; InstallNetscapePlugin
;
; Replace 'mynetscapeplugin.dll' with the name of your DLL to extract.
;
; (pretty much untested, but should work)
;
; you may want to add is-netscape-running and error checking (if the file isn't writable)
Function InstallNetscapePlugin
Push $OUTDIR
Push $0
Push $1
StrCpy $0 0
outer_loop:
EnumRegKey $1 HKLM "Software\Netscape\Netscape Navigator" $0
StrCmp $1 "" abort
ReadRegStr $1 HKLM "Software\Netscape\Netscape Navigator\$1\Main" "Plugins Directory"
StrCmp $1 "" abort
SetOutPath $1
File mynetscapeplugin.dll
IntOp $0 $0 + 1
Goto outer_loop
abort:
Pop $1
Pop $0
Pop $OUTDIR
FunctionEnd
<A name=RemoveNetscapePlugin>;------------------------------------------------------------------------------
; un.RemoveNetscapePlugin
;
; input: top of stack = dll name of plugin to remove
; output: none
;
; Usage:
; Push mynetscapepluging.dll
; Call un.RemoveNetscapePlugin
;
; you may want to add is-netscape-running and error checking (if the delete doesn't work).
Function un.RemoveNetscapePlugin
Exch $2
Push $0
Push $1
StrCpy $0 0
outer_loop:
EnumRegKey $1 HKLM "Software\Netscape\Netscape Navigator" $0
StrCmp $1 "" abort
ReadRegStr $1 HKLM "Software\Netscape\Netscape Navigator\$1\Main" "Plugins Directory"
StrCmp $1 "" abort
Delete /REBOOTOK $1\$2
IntOp $0 $0 + 1
Goto outer_loop
abort:
Pop $1
Pop $0
Pop $2
FunctionEnd
</PRE></A></BODY></HTML>

86
Examples/gfx.nsi Normal file
View file

@ -0,0 +1,86 @@
; gfx.nsi
;
; This script shows some examples of using all of the new
; graphic related additions made in NSIS 1.99
;
; Written by Amir Szkeley 22nd July 2002
;
Name "Graphical effects"
OutFile "gfx.exe"
; Adds an XP manifest to the installer
XPStyle on
; Add branding image to the installer (an image on the side)
AddBrandingImage left 100
; Sets the font of the installer
SetFont "Comic Sans MS" 8
; Just to make it three pages...
SubCaption 0 ": Yet another page..."
SubCaption 2 ": Yet another page..."
LicenseText "Second page"
LicenseData "gfx.nsi"
DirText "Lets make a third page!"
; Install dir
InstallDir "${NSISDIR}\Examples"
; Branding helper functions
!include "branding.nsh"
Function .onInit
!insertmacro BI_INIT $R0
FunctionEnd
Function .onNextPage
!insertmacro BI_NEXT
FunctionEnd
Function .onPrevPage
!insertmacro BI_PREV
FunctionEnd
!insertmacro BI_LIST
!insertmacro BI_LIST_ADD "${NSISDIR}\Contrib\Icons\checks1.bmp" /RESIZETOFIT
!insertmacro BI_LIST_ADD "${NSISDIR}\Contrib\Icons\checks2.bmp" /RESIZETOFIT
!insertmacro BI_LIST_ADD "${NSISDIR}\Contrib\Icons\checks4.bmp" /RESIZETOFIT
!insertmacro BI_LIST_END
Section
; You can also use the BI_NEXT macro here...
MessageBox MB_YESNO "We can change the branding image from within a section too!$\nDo you want me to change it?" IDNO done
GetTempFileName $1
File /oname=$1 "${NSISDIR}\Contrib\Icons\checksX2.bmp"
SetBrandingImage $1
Delete $1
done:
WriteUninstaller uninst.exe
SectionEnd
; Another page for uninstaller
UninstallText "Another page..."
; Uninstall branding helper functions
!define BI_UNINSTALL
!include "branding.nsh"
Function un.onInit
!insertmacro BI_INIT $R0
FunctionEnd
Function un.onNextPage
!insertmacro BI_NEXT
FunctionEnd
!insertmacro BI_LIST
!insertmacro BI_LIST_ADD "${NSISDIR}\Contrib\Icons\checksX.bmp" /RESIZETOFIT
!insertmacro BI_LIST_ADD "${NSISDIR}\Contrib\Icons\jarsonic-checks.bmp" /RESIZETOFIT
!insertmacro BI_LIST_END
Section uninstall
MessageBox MB_OK "Bla"
SectionEnd

420
Examples/makensis.nsi Normal file
View file

@ -0,0 +1,420 @@
!define VER_MAJOR 2
!define VER_MINOR 0a2
!ifdef NO_COMPRESSION
SetCompress off
SetDatablockOptimize off
!endif
!ifdef NO_CRC
CRCCheck off
!endif
Name "NSIS"
Caption "Nullsoft Install System - Setup"
OutFile nsis${VER_MAJOR}${VER_MINOR}.exe
SetCompressor bzip2
!ifdef uglyinstaller
BGGradient 000000 308030 FFFFFF
InstallColors FF8080 000000
InstProgressFlags smooth colored
XPStyle on
!else
WindowIcon off
!endif
!ifdef NSIS_CONFIG_LICENSEPAGE
LicenseText "You must read the following license before installing:"
LicenseData ..\license.txt
!endif
!ifdef NSIS_CONFIG_COMPONENTPAGE
ComponentText "This will install the Nullsoft Install System v${VER_MAJOR}.${VER_MINOR} on your computer:"
InstType "Full (w/ Source and Contrib)"
InstType "Normal (w/ Contrib, w/o Source)"
InstType "Lite (w/o Source or Contrib)"
!endif
AutoCloseWindow false
ShowInstDetails show
ShowUninstDetails show
DirText "Please select a location to install NSIS (or use the default):"
SetOverwrite on
SetDateSave on
!ifdef HAVE_UPX
!packhdr tmp.dat "upx\upx --best --compress-icons=1 tmp.dat"
!endif
InstallDir $PROGRAMFILES\NSIS
InstallDirRegKey HKLM SOFTWARE\NSIS ""
Section "NSIS development system (required)"
SectionIn 1 2 3 RO
SetOutPath $INSTDIR
SetOverwrite try
File ..\makensis.exe
File ..\makensisw.exe
File ..\makensis.htm
File ..\license.txt
SetOverwrite off
File ..\nsisconf.nsi
SectionEnd
Section "NSIS Examples (recommended)"
SectionIn 1 2 3
SetOutPath $INSTDIR\Examples
SetOverwrite try
Delete $INSTDIR\*.nsh
Delete $INSTDIR\viewhtml.nsi
Delete $INSTDIR\waplugin.nsi
Delete $INSTDIR\example*.nsi
Delete $INSTDIR\*test.nsi
Delete $INSTDIR\primes.nsi
Delete $INSTDIR\functions.htm
File ..\Examples\makensis.nsi
File ..\Examples\example1.nsi
File ..\Examples\example2.nsi
File ..\Examples\viewhtml.nsi
File ..\Examples\waplugin.nsi
File ..\Examples\bigtest.nsi
File ..\Examples\primes.nsi
File ..\Examples\rtest.nsi
File ..\Examples\gfx.nsi
File ..\Examples\WinMessages.nsh
File ..\Examples\branding.nsh
File ..\Examples\functions.htm
SectionEnd
Section "NSI Development Shell Extensions"
SectionIn 1 2 3
; back up old value of .nsi
ReadRegStr $1 HKCR ".nsi" ""
StrCmp $1 "" Label1
StrCmp $1 "NSISFile" Label1
WriteRegStr HKCR ".nsi" "backup_val" $1
Label1:
WriteRegStr HKCR ".nsi" "" "NSISFile"
WriteRegStr HKCR "NSISFile" "" "NSI Script File"
WriteRegStr HKCR "NSISFile\shell" "" "open"
WriteRegStr HKCR "NSISFile\DefaultIcon" "" $INSTDIR\makensis.exe,0
WriteRegStr HKCR "NSISFile\shell\open\command" "" 'notepad.exe "%1"'
WriteRegStr HKCR "NSISFile\shell\compile" "" "Compile NSI"
WriteRegStr HKCR "NSISFile\shell\compile\command" "" '"$INSTDIR\makensisw.exe" "$INSTDIR\makensis.exe" /CD "%1"'
WriteRegStr HKCR "NSISFile\shell\compile-bz2" "" "Compile NSI (with bz2)"
WriteRegStr HKCR "NSISFile\shell\compile-bz2\command" "" '"$INSTDIR\makensisw.exe" "$INSTDIR\makensis.exe" /CD /X"SetCompressor bzip2" "%1"'
SectionEnd
Section "Start Menu + Desktop Icons"
SectionIn 1 2 3
SetOutPath $SMPROGRAMS\NSIS
Delete "$SMPROGRAMS\NSIS\NSIS Home Page.lnk"
WriteINIStr "$SMPROGRAMS\NSIS\NSIS Home Page.url" "InternetShortcut" "URL" "http://www.nullsoft.com/free/nsis/"
CreateShortCut "$SMPROGRAMS\NSIS\Uninstall NSIS.lnk" "$INSTDIR\uninst-nsis.exe"
CreateShortCut "$SMPROGRAMS\NSIS\NSIS Documentation.lnk" "$INSTDIR\makensis.htm"
CreateShortCut "$SMPROGRAMS\NSIS\NSIS Program Directory.lnk" "$INSTDIR"
Delete "$SMPROGRAMS\NSIS\NSI Online Template Generator.lnk"
WriteINIStr "$SMPROGRAMS\NSIS\NSI Online Template Generator.url" "InternetShortcut" "URL" "http://www.firehose.net/free/nsis/makensitemplate.phtml"
SetOutPath $INSTDIR
CreateShortCut "$DESKTOP\MakeNSIS.lnk" "$INSTDIR\Makensisw.exe" '"$INSTDIR\makensis.exe" /CD'
SectionEnd
!ifndef NO_CONTRIB
SubSection "Additional utilities"
SubSection "Contrib"
Section "Extra Icons"
SectionIn 1 2
SetOutPath $INSTDIR\Contrib\Icons
SetOverwrite try
Delete $INSTDIR\Contrib\*.ico
Delete $INSTDIR\Contrib\*.bmp
File ..\Contrib\Icons\*.ico
File ..\Contrib\Icons\*.bmp
SetOutPath $INSTDIR
SectionEnd
Section "Extra UIs"
SectionIn 1 2
SetOutPath $INSTDIR\Contrib\UIs
SetOverwrite try
File ..\Contrib\UIs\*.exe
SetOutPath $INSTDIR
SectionEnd
Section "Splash"
SectionIn 1 2
SetOutPath $INSTDIR\Contrib\Splash
SetOverwrite try
File ..\Contrib\Splash\splash.c
File ..\Contrib\Splash\splash.dsp
File ..\Contrib\Splash\splash.dsw
File ..\Contrib\splash\splash.txt
SetOutPath $INSTDIR\Bin
File ..\Bin\splash.exe
IfFileExists $SMPROGRAMS\NSIS 0 NoShortCuts
CreateDirectory $SMPROGRAMS\NSIS\Contrib
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\Splash Screen Help.lnk" "$INSTDIR\contrib\splash\splash.txt"
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\Splash project workspace.lnk" "$INSTDIR\source\splash\splash.dsw"
NoShortCuts:
SectionEnd
Section "Zip2Exe"
SectionIn 1 2
DetailPrint "Extracting zip2exe source"
SetDetailsPrint textonly
RMDir /r $INSTDIR\Source\Zip2Exe
SetOutPath $INSTDIR\Contrib\zip2exe
SetOverwrite try
File ..\Contrib\zip2exe\*.cpp
File ..\Contrib\zip2exe\*.ico
File ..\Contrib\zip2exe\*.h
File ..\Contrib\zip2exe\*.rc
File ..\Contrib\zip2exe\*.dsw
File ..\Contrib\zip2exe\*.dsp
SetOutPath $INSTDIR\Contrib\zip2exe\zlib
File ..\Contrib\zip2exe\zlib\*.*
SetOutPath $INSTDIR\Bin
File ..\Bin\zip2exe.exe
SetDetailsPrint both
IfFileExists $SMPROGRAMS\NSIS 0 NoShortCuts
CreateDirectory $SMPROGRAMS\NSIS\Contrib
Delete "$SMPROGRAMS\Bin\NSIS\ZIP2EXE converter.lnk"
Delete "$SMPROGRAMS\NSIS\ZIP2EXE project workspace.lnk"
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\ZIP2EXE converter.lnk" "$INSTDIR\Bin\zip2exe.exe"
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\ZIP2EXE project workspace.lnk" "$INSTDIR\source\zip2exe\zip2exe.dsw"
NoShortCuts:
SectionEnd
Section "InstallOptions"
SectionIn 1 2
SetOutPath $INSTDIR\Contrib\InstallOptions
SetOverwrite try
File ..\contrib\installoptions\io.dsp
File ..\contrib\installoptions\io.dsw
File ..\contrib\installoptions\test.ini
File ..\contrib\installoptions\test.nsi
File ..\contrib\installoptions\InstallerOptions.cpp
File ..\contrib\installoptions\*.rc
File ..\contrib\installoptions\*.h
File "..\contrib\installoptions\Install Options.html"
SetOutPath $INSTDIR\Bin
File ..\Bin\InstallOptions.dll
IfFileExists $SMPROGRAMS\NSIS 0 NoShortCuts
CreateDirectory $SMPROGRAMS\NSIS\Contrib
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\InstallOptions Readme.lnk" "$INSTDIR\contrib\InstallOptions\install options.html"
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\InstallOptions project workspace.lnk" "$INSTDIR\contrib\InstallOptions\io.dsw"
NoShortCuts:
SectionEnd
Section "NSIS-DL"
SectionIn 1 2
SetOutPath $INSTDIR\Contrib\NSISdl
SetOverwrite try
File ..\contrib\NSISdl\nsisdl.dsw
File ..\contrib\NSISdl\nsisdl.dsp
File ..\contrib\NSISdl\*.cpp
File ..\contrib\NSISdl\*.h
File ..\contrib\NSISdl\*.rc
File ..\contrib\NSISdl\ReadMe.txt
SetOutPath $INSTDIR\Bin
File ..\Bin\nsisdl.dll
IfFileExists $SMPROGRAMS\NSIS 0 NoShortCuts
CreateDirectory $SMPROGRAMS\NSIS\Contrib
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\NSIS-DL Readme.lnk" "$INSTDIR\contrib\NSISDL\ReadMe.txt"
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\NSIS-DL project workspace.lnk" "$INSTDIR\contrib\NSISDL\nsisdl.dsw"
NoShortCuts:
SectionEnd
SubSectionEnd
SubSectionEnd
!endif
!ifndef NO_SOURCE
SubSection "Source code"
Section "NSIS Source Code"
SectionIn 1
DetailPrint "Extracting source code...."
SetDetailsPrint textonly
SetOutPath $INSTDIR\Source
SetOverwrite try
File ..\Source\*.cpp
File ..\Source\*.c
File ..\Source\*.h
File ..\Source\script1.rc
File ..\Source\Makefile
File ..\Source\makenssi.dsp
File ..\Source\makenssi.dsw
File ..\Source\icon.ico
SetOutPath $INSTDIR\Source\zlib
File ..\Source\zlib\*.*
SetOutPath $INSTDIR\Source\bzip2
File ..\Source\bzip2\*.*
SetOutPath $INSTDIR\Source\exehead
File ..\Source\exehead\*.c
File ..\Source\exehead\*.h
File ..\Source\exehead\exehead.xml
File ..\Source\exehead\resource.rc
File ..\Source\exehead\*.dsp
File ..\Source\exehead\Makefile
File ..\Source\exehead\nsis.ico
File ..\Source\exehead\uninst.ico
File ..\Source\exehead\bitmap1.bmp
File ..\Source\exehead\bin2h.exe
IfFileExists $SMPROGRAMS\NSIS 0 NoSourceShortCuts
CreateShortCut "$SMPROGRAMS\NSIS\MakeNSIS project workspace.lnk" "$INSTDIR\source\makenssi.dsw"
NoSourceShortCuts:
SetDetailsPrint both
SectionEnd
SubSection "Contrib"
Section "ExDLL Source"
SectionIn 1
SetOutPath $INSTDIR\Contrib\ExDLL
SetOverwrite try
File ..\contrib\exdll\exdll.c
File ..\contrib\exdll\exdll.dpr
File ..\contrib\exdll\exdll.dsp
File ..\contrib\exdll\exdll.dsw
SetOutPath $INSTDIR
IfFileExists $SMPROGRAMS\NSIS 0 NoShortCuts
CreateDirectory $SMPROGRAMS\NSIS\Contrib
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\ExDLL project workspace.lnk" "$INSTDIR\contrib\ExDLL\exdll.dsw"
NoShortCuts:
SectionEnd
Section "MakeNSISW Source"
SectionIn 1
SetOutPath $INSTDIR\Contrib\Makensisw
SetOverwrite try
File ..\contrib\makensisw\*.cpp
File ..\contrib\makensisw\*.xml
File ..\contrib\makensisw\*.h
File ..\contrib\makensisw\*.ds?
File ..\contrib\makensisw\*.rc
File ..\contrib\makensisw\*.txt
#File ..\contrib\makensisw\Makefile
IfFileExists $SMPROGRAMS\NSIS 0 NoShortCuts
CreateDirectory $SMPROGRAMS\NSIS\Contrib
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\MakeNSISW project workspace.lnk" "$INSTDIR\contrib\MakeNsisw\makensisw.dsw"
CreateShortCut "$SMPROGRAMS\NSIS\Contrib\MakeNSISW readme.lnk" "$INSTDIR\contrib\MakeNsisw\readme.txt"
NoShortCuts:
SectionEnd
SubSectionEnd
SubSectionEnd
!endif
Section -post
WriteRegStr HKLM SOFTWARE\NSIS "" $INSTDIR
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "DisplayName" "NSIS Development Kit (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "UninstallString" '"$INSTDIR\uninst-nsis.exe"'
SetOutPath $INSTDIR
IfFileExists $SMPROGRAMS\NSIS "" nofunshit
ExecShell open '$SMPROGRAMS\NSIS'
Sleep 500
BringToFront
nofunshit:
; since the installer is now created last (in 1.2+), this makes sure
; that any old installer that is readonly is overwritten.
Delete $INSTDIR\uninst-nsis.exe
WriteUninstaller $INSTDIR\uninst-nsis.exe
SectionEnd
Function .onInstSuccess
MessageBox MB_YESNO|MB_ICONQUESTION "Setup has completed. View readme file now?" IDNO NoReadme
ExecShell open '$INSTDIR\makensis.htm'
NoReadme:
FunctionEnd
!ifndef NO_UNINST
UninstallText "This will uninstall NSIS from your system:"
Section Uninstall
IfFileExists $INSTDIR\makensis.exe skip_confirmation
MessageBox MB_YESNO "It does not appear that NSIS is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)" IDYES skip_confirmation
Abort "Uninstall aborted by user"
skip_confirmation:
ReadRegStr $1 HKCR ".nsi" ""
StrCmp $1 "NSISFile" 0 NoOwn ; only do this if we own it
ReadRegStr $1 HKCR ".nsi" "backup_val"
StrCmp $1 "" 0 RestoreBackup ; if backup == "" then delete the whole key
DeleteRegKey HKCR ".nsi"
Goto NoOwn
RestoreBackup:
WriteRegStr HKCR ".nsi" "" $1
DeleteRegValue HKCR ".nsi" "backup_val"
NoOwn:
DeleteRegKey HKCR "NSISFile"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS"
DeleteRegKey HKLM SOFTWARE\NSIS
Delete $SMPROGRAMS\NSIS\Contrib\*.lnk
Delete $SMPROGRAMS\NSIS\Contrib\*.url
RMDir $SMPROGRAMS\NSIS\Contrib
RMDir /r $INSTDIR\Contrib
Delete $SMPROGRAMS\NSIS\*.lnk
Delete $SMPROGRAMS\NSIS\*.url
RMDir $SMPROGRAMS\NSIS
Delete $DESKTOP\MakeNSIS.lnk
Delete $INSTDIR\makensis*.exe
Delete $INSTDIR\Bin\zip2exe.exe
Delete $INSTDIR\Bin\installoptions.exe
Delete $INSTDIR\Bin\installoptions.dll
Delete $INSTDIR\Bin\splash.txt
Delete $INSTDIR\Bin\splash.exe
Delete $INSTDIR\Bin\nsisdl.dll
Delete $INSTDIR\makensis.htm
Delete $INSTDIR\Examples\functions.htm
Delete $INSTDIR\makensis.rtf
Delete $INSTDIR\uninst-nsis.exe
Delete $INSTDIR\nsisconf.nsi
Delete $INSTDIR\Examples\makensis.nsi
Delete $INSTDIR\Examples\example1.nsi
Delete $INSTDIR\Examples\example2.nsi
Delete $INSTDIR\Examples\waplugin.nsi
Delete $INSTDIR\Examples\viewhtml.nsi
Delete $INSTDIR\Examples\bigtest.nsi
Delete $INSTDIR\Examples\primes.nsi
Delete $INSTDIR\Examples\rtest.nsi
Delete $INSTDIR\Examples\uglytest.nsi
Delete $INSTDIR\Examples\spin.nsi
Delete $INSTDIR\Examples\wafull.nsi
Delete $INSTDIR\Examples\upgradedll.nsh
Delete $INSTDIR\Examples\WinMessages.nsh
Delete $INSTDIR\main.ico
Delete $INSTDIR\makensis-license.txt
Delete $INSTDIR\license.txt
Delete $INSTDIR\uninst.ico
Delete $INSTDIR\bitmap1.bmp
Delete $INSTDIR\bitmap2.bmp
RMDir /r $INSTDIR\Source
RMDir /r $INSTDIR\Bin
RMDir /r $INSTDIR\Examples
RMDir $INSTDIR
; if $INSTDIR was removed, skip these next ones
IfFileExists $INSTDIR 0 Removed
MessageBox MB_YESNO|MB_ICONQUESTION \
"Remove all files in your NSIS directory? (If you have anything you created that you want to keep, click No)" IDNO Removed
Delete $INSTDIR\*.* ; this would be skipped if the user hits no
RMDir /r $INSTDIR
IfFileExists $INSTDIR 0 Removed
MessageBox MB_OK|MB_ICONEXCLAMATION "Note: $INSTDIR could not be removed."
Removed:
SectionEnd
!endif

48
Examples/primes.nsi Normal file
View file

@ -0,0 +1,48 @@
Name "primes"
AllowRootDirInstall true
OutFile "primes.exe"
Caption "Prime number generator"
ShowInstDetails show
AllowRootDirInstall true
InstallDir "$EXEDIR"
DirText "Select directory to write primes.txt"
Section "crap"
SetOutPath $INSTDIR
Call DoPrimes
SectionEnd
Function DoPrimes
; we put this in here so it doesn't update the progress bar (faster)
!define PPOS $0 ; position in prime searching
!define PDIV $1 ; divisor
!define PMOD $2 ; the result of the modulus
!define PCNT $3 ; count of how many we've printed
FileOpen $9 $INSTDIR\primes.txt w
DetailPrint "2 is prime!"
FileWrite $9 "2 is prime!$\r$\n"
DetailPrint "3 is prime!"
FileWrite $9 "3 is prime!$\r$\n"
Strcpy ${PPOS} 3
Strcpy ${PCNT} 2
outerloop:
StrCpy ${PDIV} 3
innerloop:
IntOp ${PMOD} ${PPOS} % ${PDIV}
IntCmp ${PMOD} 0 notprime
IntOp ${PDIV} ${PDIV} + 2
IntCmp ${PDIV} ${PPOS} 0 innerloop 0
DetailPrint "${PPOS} is prime!"
FileWrite $9 "${PPOS} is prime!$\r$\n"
IntOp ${PCNT} ${PCNT} + 1
IntCmp ${PCNT} 100 0 innerloop
StrCpy ${PCNT} 0
MessageBox MB_YESNO "Process more?" IDNO stop
notprime:
IntOp ${PPOS} ${PPOS} + 2
Goto outerloop
stop:
FileClose $9
FunctionEnd

56
Examples/rtest.nsi Normal file
View file

@ -0,0 +1,56 @@
Name "rtest"
OutFile "rtest.exe"
InstallDir $TEMP
BGGradient 0 FFFF00 00FFFF
DirShow hide
ComponentText "select tests."
Section "test 1"
StrCpy $0 "a"
Call test1
StrCmp $0 "a182345678" success
DetailPrint "Test 1 failed (output: $0)"
Goto end
success:
DetailPrint "Test 1 succeded (output: $0)"
end:
SectionEnd
Function test1
GetLabelAddress $9 skip8
IntOp $9 $9 - 1
StrCpy $0 $01
Call $9
StrCpy $0 $02
StrCpy $0 $03
StrCpy $0 $04
StrCpy $0 $05
StrCpy $0 $06
StrCpy $0 $07
StrCpy $0 $08
skip8:
FunctionEnd
Section "test 2"
StrCpy $0 "0"
StrCpy $1 "11"
GetFunctionAddress $9 test2
Call $9
StrCmp $1 "11,10,9,8,7,6,5,4,3,2,1" success
DetailPrint "Test 2 failed (output: $1)"
Goto end
success:
DetailPrint "Test 2 succeded (output: $1)"
end:
SectionEnd
Function test2
IntOp $0 $0 + 1
IntCmp $0 10 done
Push $0
Call test2
Pop $0
done:
StrCpy $1 "$1,$0"
FunctionEnd

43
Examples/viewhtml.nsi Normal file
View file

@ -0,0 +1,43 @@
; viewhtml.nsi
;
; This script creates a silent installer which extracts one (or more) HTML
; files to a temporary directory, opens Internet Explorer to view the file(s),
; and when Internet Explorer has quit, deletes the file(s).
;
; The name of the installer (not really used in a silent install)
Name "ViewHTML"
; Set to silent mode
SilentInstall silent
; The file to write
OutFile "viewhtml.exe"
; The installation directory (the user never gets to change this)
InstallDir "$TEMP\ViewHTML"
; The stuff to install
Section ""
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Extract file
File "..\makensis.htm"
; View file
ExecWait '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$INSTDIR\makensis.htm"'
; Delete the files
Delete $INSTDIR\Makensis.htm
RMDir $INSTDIR
SectionEnd
; Note: another way of doing this would be to use ExecShell, but then you
; really couldn't get away with deleting the files. Here is the ExecShell
; line that you would want to use:
;
; ExecShell "open" '"$INSTDIR\makensis.htm"'
;
; The advantage of this way is that it would use the default browser to
; open the HTML.
;
; eof

153
Examples/waplugin.nsi Normal file
View file

@ -0,0 +1,153 @@
; waplugin.nsi
;
; This script will generate an installer that installs a Winamp plug-in.
; It also puts a license page on, for shits and giggles.
;
; This installer will automatically alert the user that installation was
; successful, and ask them whether or not they would like to make the
; plug-in the default and run Winamp.
;
; The name of the installer
Name "TinyVis Plug-in"
; The file to write
OutFile "waplugin.exe"
; License page
; LicenseText "This installer will install the Nullsoft Tiny Visualization 2000 Plug-in for Winamp. Please read the license below."
; use the default makensis license :)
; LicenseData license.txt
; The default installation directory
InstallDir $PROGRAMFILES\Winamp
; detect winamp path from uninstall string if available
InstallDirRegKey HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"
; The text to prompt the user to enter a directory
DirText "Please select your Winamp path below (you will be able to proceed when Winamp is detected):"
DirShow hide
; automatically close the installer when done.
AutoCloseWindow true
; hide the "show details" box
ShowInstDetails nevershow
Function .onVerifyInstDir
!ifndef WINAMP_AUTOINSTALL
IfFileExists $INSTDIR\Winamp.exe Good
Abort
Good:
!endif ; WINAMP_AUTOINSTALL
FunctionEnd
Function QueryWinampVisPath ; sets $1 with vis path
StrCpy $1 $INSTDIR\Plugins
; use DSPDir instead of VISDir to get DSP plugins directory
ReadINIStr $9 $INSTDIR\winamp.ini Winamp VisDir
StrCmp $9 "" End
IfFileExists $9 0 End
StrCpy $1 $9 ; update dir
End:
FunctionEnd
!ifdef WINAMP_AUTOINSTALL
Function GetWinampInstPath
Push $0
Push $1
Push $2
ReadRegStr $0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"
StrCmp $0 "" fin
StrCpy $1 $0 1 0 ; get firstchar
StrCmp $1 '"' "" getparent
; if first char is ", let's remove "'s first.
StrCpy $0 $0 "" 1
StrCpy $1 0
rqloop:
StrCpy $2 $0 1 $1
StrCmp $2 '"' rqdone
StrCmp $2 "" rqdone
IntOp $1 $1 + 1
Goto rqloop
rqdone:
StrCpy $0 $0 $1
getparent:
; the uninstall string goes to an EXE, let's get the directory.
StrCpy $1 -1
gploop:
StrCpy $2 $0 1 $1
StrCmp $2 "" gpexit
StrCmp $2 "\" gpexit
IntOp $1 $1 - 1
Goto gploop
gpexit:
StrCpy $0 $0 $1
StrCmp $0 "" fin
IfFileExists $0\winamp.exe fin
StrCpy $0 ""
fin:
Pop $2
Pop $1
Exch $0
FunctionEnd
Function MakeSureIGotWinamp
Call GetWinampInstPath
Pop $0
StrCmp $0 "" getwinamp
Return
getwinamp:
StrCpy $1 $TEMP\porearre1.dll
StrCpy $2 "$TEMP\Winamp Installer.exe"
File /oname=$1 nsisdl.dll
Push http://download.nullsoft.com/winamp/client/winamp277_lite.exe
Push $2
CallInstDLL $1 download
Delete $1
StrCmp $0 success success
SetDetailsView show
DetailPrint "download failed: $0"
Abort
success:
ExecWait '"$2" /S'
Delete $2
Call GetWinampInstPath
Pop $0
StrCmp $0 "" skip
StrCpy $INSTDIR $0
skip:
FunctionEnd
!endif ; WINAMP_AUTOINSTALL
; The stuff to install
Section "ThisNameIsIgnoredSoWhyBother?"
!ifdef WINAMP_AUTOINSTALL
Call MakeSureIGotWinamp
!endif
Call QueryWinampVisPath
SetOutPath $1
; File to extract
File "C:\program files\winamp\plugins\vis_nsfs.dll"
; prompt user, and if they select no, skip the following 3 instructions.
MessageBox MB_YESNO|MB_ICONQUESTION \
"The plug-in was installed. Would you like to run Winamp now with TinyVis as the default plug-in?" \
IDNO NoWinamp
WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_name" "vis_nsfs.dll"
WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_num" "0"
Exec '"$INSTDIR\Winamp.exe"'
NoWinamp:
SectionEnd
; eof