~itmages/itmages/itmages-windows-extension

« back to all changes in this revision

Viewing changes to installer/itmages.nsi

  • Committer: Dmitry
  • Date: 2012-03-11 07:56:24 UTC
  • Revision ID: git-v1:d5a30bf1fe74b46641b08d0151d39dba15b67f0e
Migrate from launchpad

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!include "MUI.nsh"
 
2
 
 
3
; Application's version
 
4
!define VERSION "0.3"
 
5
 
 
6
; Application's name
 
7
!define APP_NAME "ITmages upload client"
 
8
 
 
9
; Default icon for the installer
 
10
!define MUI_ICON "D:\itmages.ico"
 
11
 
 
12
; Enables exit warning dialog
 
13
!define MUI_ABORTWARNING
 
14
 
 
15
; Setting application's name
 
16
name "${APP_NAME}"
 
17
 
 
18
; Name of the installation file
 
19
OutFile "itmages-extension-${VERSION}-win32.exe"
 
20
 
 
21
; Default installation directory
 
22
InstallDir "$PROGRAMFILES\ITmages"
 
23
 
 
24
; Compression type
 
25
SetCompressor lzma
 
26
 
 
27
; Variables
 
28
Var StartMenuFolder
 
29
 
 
30
;Request application privileges for Windows Vista and Windows 7
 
31
RequestExecutionLevel user
 
32
 
 
33
; Install sections
 
34
!insertmacro MUI_PAGE_WELCOME
 
35
!insertmacro MUI_PAGE_LICENSE "D:\ITmages\docs\COPYING.txt"
 
36
!insertmacro MUI_PAGE_DIRECTORY
 
37
 
 
38
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
 
39
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\ITmages" 
 
40
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
 
41
  
 
42
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
 
43
!insertmacro MUI_PAGE_INSTFILES
 
44
 
 
45
; Uninstall sections
 
46
!insertmacro MUI_UNPAGE_WELCOME
 
47
!insertmacro MUI_UNPAGE_CONFIRM
 
48
!insertmacro MUI_UNPAGE_INSTFILES
 
49
 
 
50
;Languages
 
51
!insertmacro MUI_LANGUAGE "Russian"
 
52
!insertmacro MUI_LANGUAGE "English"
 
53
 
 
54
; Associates ITmages client with the selected file extension
 
55
Function AssociateWithExtension
 
56
 
 
57
Exch $0
 
58
 
 
59
${if} $LANGUAGE = 1049
 
60
        WriteRegStr HKCR "SystemFileAssociations\$0\Shell\itmagesupload" "" "��������� �� ITmages"
 
61
${elseif} $LANGUAGE = 1033
 
62
        WriteRegStr HKCR "SystemFileAssociations\$0\Shell\itmagesupload" "" "Upload to ITmages"
 
63
${endif}
 
64
 
 
65
WriteRegStr HKCR "SystemFileAssociations\$0\Shell\itmagesupload" "Icon" "$INSTDIR\itmages.exe,0"
 
66
WriteRegStr HKCR "SystemFileAssociations\$0\Shell\itmagesupload\Command" "" "$INSTDIR\itmages.exe %1"
 
67
 
 
68
Pop $0
 
69
 
 
70
FunctionEnd
 
71
 
 
72
; Checks if the application was already installed
 
73
Function IsInstalled
 
74
 
 
75
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages" "UninstallString"
 
76
 
 
77
StrCmp $R0 "" NotInstalled +1
 
78
${if} $LANGUAGE = 1049
 
79
        messagebox::show MB_DEFBUTTON4|MB_TOPMOST "ITmages upload client" \
 
80
                "0,103" \
 
81
                "ITmages upload client ��� ����������." \
 
82
                "�������" "������"
 
83
${elseif} $LANGUAGE = 1033
 
84
        messagebox::show MB_DEFBUTTON4|MB_TOPMOST "ITmages upload client" \
 
85
                "0,103" \
 
86
                "ITmages upload client is already installed." \
 
87
                "Uninstall" "Cancel"
 
88
${endif}
 
89
Pop $R1
 
90
StrCmp $R1 2 Quit +1
 
91
Exec $R0
 
92
Quit:
 
93
  Quit
 
94
NotInstalled:
 
95
Call InstallLanguage
 
96
 
 
97
FunctionEnd
 
98
 
 
99
; Installer language selection function
 
100
Function InstallLanguage
 
101
 
 
102
Push ""
 
103
Push ${LANG_ENGLISH}
 
104
Push English
 
105
Push ${LANG_RUSSIAN}
 
106
Push �������
 
107
Push A
 
108
LangDLL::LangDialog "Choose the language" "Select the language of the installer"
 
109
Pop $LANGUAGE
 
110
StrCmp $LANGUAGE "cancel" 0 +2
 
111
        Abort
 
112
 
 
113
FunctionEnd
 
114
 
 
115
;Uninstaller language selection function
 
116
Function un.UninstallLanguage
 
117
 
 
118
Push ""
 
119
Push ${LANG_ENGLISH}
 
120
Push English
 
121
Push ${LANG_RUSSIAN}
 
122
Push �������
 
123
Push A
 
124
LangDLL::LangDialog "Choose the language" "Select the language of the uninstaller"
 
125
Pop $LANGUAGE
 
126
StrCmp $LANGUAGE "cancel" 0 +2
 
127
        Abort
 
128
 
 
129
FunctionEnd
 
130
 
 
131
Section "ITmages" SecMain
 
132
 
 
133
; Installation files
 
134
SetOutPath "$INSTDIR"
 
135
File "D:\ITmages\"
 
136
 
 
137
SetOutPath "$INSTDIR\docs"
 
138
File "D:\ITmages\docs\"
 
139
 
 
140
SetOutPath "$INSTDIR\locale\ru\LC_MESSAGES"
 
141
File "D:\ITmages\locale\ru\LC_MESSAGES\"
 
142
 
 
143
; Creating uninstaller
 
144
WriteUninstaller "$INSTDIR\uninstall.exe"
 
145
 
 
146
; Putting information about the application to the registry
 
147
WriteRegStr HKCU "Software\ITmages" "" $INSTDIR
 
148
 
 
149
; Creating startmenu entry
 
150
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
 
151
 
 
152
        CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
 
153
        ${if} $LANGUAGE = 1049
 
154
                CreateShortCut "$SMPROGRAMS\$StartMenuFolder\ITmages - ������ ��� �������� �����������.lnk" "$INSTDIR\itmages.exe"  
 
155
        ${elseif} $LANGUAGE = 1033
 
156
                CreateShortCut "$SMPROGRAMS\$StartMenuFolder\ITmages Upload Client.lnk" "$INSTDIR\itmages.exe"  
 
157
        ${endif}
 
158
        CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"  
 
159
 
 
160
!insertmacro MUI_STARTMENU_WRITE_END
 
161
 
 
162
; Creating desktop shourtcut
 
163
${if} $LANGUAGE = 1049
 
164
        CreateShortCut "$DESKTOP\ITmages - ������ ��� �������� �����������.lnk" "$INSTDIR\itmages.exe"
 
165
${elseif} $LANGUAGE = 1033
 
166
        CreateShortCut "$DESKTOP\ITmages Upload Client.lnk" "$INSTDIR\itmages.exe"
 
167
${endif}
 
168
 
 
169
; Registry strings to add uninstall information to Add/Remove programs
 
170
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages" "DisplayName" "ITmages upload client"
 
171
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
 
172
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages" "DisplayIcon" "$\"$INSTDIR\itmages.exe$\""
 
173
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages" "Publisher" "ITmages"
 
174
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages" "DisplayVersion" "${VERSION}"
 
175
 
 
176
; Create association with png files
 
177
Push ".png"
 
178
Call AssociateWithExtension
 
179
 
 
180
; Create association with jpeg files
 
181
Push ".jpeg"
 
182
Call AssociateWithExtension
 
183
 
 
184
; Create association with jpg files
 
185
Push ".jpg"
 
186
Call AssociateWithExtension
 
187
 
 
188
; Create association with gif files
 
189
Push ".gif"
 
190
Call AssociateWithExtension
 
191
 
 
192
SectionEnd
 
193
 
 
194
Function .onInit 
 
195
 
 
196
Call IsInstalled
 
197
 
 
198
FunctionEnd
 
199
 
 
200
Section "Uninstall"
 
201
; Removing application's directory
 
202
RMDir /r "$INSTDIR"
 
203
 
 
204
; Removing startmenu entry
 
205
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder    
 
206
RMDir /r "$SMPROGRAMS\$StartMenuFolder"
 
207
 
 
208
; Removing desktop shortcat
 
209
Delete "$DESKTOP\ITmages*.lnk"
 
210
 
 
211
; Removing "Upload to ITmages" action from the context menu
 
212
DeleteRegKey HKCR "SystemFileAssociations\.png\Shell\itmagesupload"
 
213
DeleteRegKey HKCR "SystemFileAssociations\.jpeg\Shell\itmagesupload"
 
214
DeleteRegKey HKCR "SystemFileAssociations\.jpg\Shell\itmagesupload"
 
215
DeleteRegKey HKCR "SystemFileAssociations\.gif\Shell\itmagesupload"
 
216
 
 
217
; Removing the uninstall information from the registry
 
218
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ITmages"
 
219
 
 
220
; Removing information about the application from the registry
 
221
DeleteRegKey /ifempty HKCU "Software\ITmages"
 
222
 
 
223
SectionEnd
 
224
 
 
225
Function un.onInit
 
226
 
 
227
Call un.UninstallLanguage
 
228
 
 
229
FunctionEnd