summaryrefslogtreecommitdiff
path: root/Docs/src/library.but
blob: 97c61bf8ff07490c4f146edce63865fb35fe5b52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
\A{library} DLL/TLB Library Setup


\H{library_intro} Introduction

NSIS 2.01 features a new system for the installation and uninstallation of dynamic link libraries (DLL) and type libraries (TLB).
Using this new system you can handle the complete setup with one single line of code:

\b File copying

\b File copying on reboot

\b Version checks

\b Registration and unregistration

\b Registration and unregistration on reboot

\b Shared DLL counting

\b Windows File Protection checks

The macros are stored in the header file Library.nsh, which should be included in scripts using this system:

\c !include Library.nsh

Note that the library macros are limited on non-Windows platforms. DLL version information is required when compiling on non-Windows platforms.


\H{library_install} Library Installation

\S1{} Introduction

The InstallLib macro allows you to install a library. It sets the error flag if something went wrong during library setup.

To ask the user for a reboot, if required, use the Modern UI with a Finish page or use \R{ifrebootflag}{IfRebootFlag} and make your own page or message box.

\S1{} Parameters

\c libtype shared install localfile destfile tempbasedir

\\<b\\>libtype\\</b\\>

The type of the library

DLL	-			Dynamic link library (DLL)\\<br\\>
REGDLL -		DLL that has to be registered\\<br\\>
TLB - 			Type library or DLL that contains a type LIBRARY\\<br\\>
REGDLLTLB -		DLL that has to be registered and contains a type library\\<br\\>


\\<b\\>shared\\</b\\>

Specify whether the library is shared with other applications

NOTSHARED -		The library is not shared\\<br\\>
$VARNAME -		Variable that is empty when the application is installed for the first time,
				which is when the shared library count will be increased.\\<br\\>

\\<b\\>install\\</b\\>

Specify the installation method

REBOOT_PROTECTED

\b Upgrade the library on reboot when in use (required for system files).

\b Upgrade the library if the file is not protected by Windows File Protection.

NOREBOOT_PROTECTED

\b Warns the user when the library is in use. The user will have to close applications using the library.

\b Upgrade the library if the file is not protected by Windows File Protection.

REBOOT_NOTPROTECTED

\b Upgrade the library on reboot when in use (required for system files).

\b Upgrade the library without checking for Windows File Protection.
										
NOREBOOT_NOTPROTECTED

\b Warns the user when the library is in use. The user will have to close  applications using the library.
						
\b Upgrade the library without checking for Windows File Protection.	

\\<b\\>localfile\\</b\\>

Location of the library on the compiler system

\\<b\\>destfile\\</b\\>

Location to store the library on the user's system

\\<b\\>tempbasedir\\</b\\>

Directory on the user's system to store a temporary file when the system has to be rebooted.

For Windows 9x/ME support, this directory should be on the same volume as the destination file (destfile).
The Windows temp directory could be located on any volume, so you cannot use this directory.

\S1{} Options

\R{define}{Define} any of the following before inserting the InstallLib macro to modify its behavior as specified.

\S2{} LIBRARY_X64

\b Installs a DLL built for Windows x64.

\b \\<b\\>Warning:\\</b\\> this resets file system redirection.

\S2{} LIBRARY_SHELL_EXTENSION

\b Define this before inserting InstallLib macro to call SHChangeNotify with SHCNE_ASSOCCHANGED after registration.

\b Use this to refresh the shell when installing a shell extension or when changing file associations.

\S2{} LIBRARY_COM

\b Define this before inserting InstallLib macro to call CoFreeUnusedLibraries after registration.

\b Use this for unloading all unnecessary libraries from memory when installing COM libraries.

\S2{} LIBRARY_IGNORE_VERSION

\b Define this before inserting InstallLib macro to ignore version information in the file and always install it, even if it already exists.

\b Use this when an older or specific version is required.

\b Not recommended for DLLs installed to $SYSDIR.

\S1{} Notes

\b If you want to support Windows 9x/ME, you can only use short filenames (8.3).

\b \\<b\\>Warning:\\</b\\> when deploying DLLs, always use redistributable files. Never copy files from your system directory.

\S1{} Example

\S2{} Unshared DLL

\c  !insertmacro InstallLib REGDLL NOTSHARED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR

\S2{} Shared DLL

\c  ;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is
\c  ;already installed. For example:
\c
\c  IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation ;Replace MyApp.exe with your application filename
\c    StrCpy $ALREADY_INSTALLED 1
\c  new_installation:
\c
\c  !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR

\H{library_uninstall} Library Uninstallation

\S1{} Introduction

The UnInstallLib macro allows you to uninstall a library. It sets the error flag if something went wrong during library removal.

\S1{} Parameters

\c libtype shared uninstall file

\\<b\\>libtype\\</b\\>

The type of the library

DLL	-			Dynamic link library (DLL)\\<br\\>
REGDLL -		DLL that has to be registered\\<br\\>
TLB - 			Type library or DLL that contains a type LIBRARY\\<br\\>
REGDLLTLB -		DLL that has to be registered and contains a type library\\<br\\>


\\<b\\>shared\\</b\\>

Specify whether the library is shared with other applications

NOTSHARED -		The library is not shared\\<br\\>
SHARED -		The library is shared and should be removed if the shared library count
				indicates that the file is not in use anymore..\\<br\\>

\\<b\\>uninstall\\</b\\>

Specify the uninstallation method

NOREMOVE

\b The library should not be removed. You should use this option for common or important
system files such as the Visual Basic/C++/MFC runtimes.
										
REBOOT_PROTECTED

\b Remove the library on reboot when in use (required for system files).

\b Remove the library if the file is not protected by Windows File Protection.
										
NOREBOOT_PROTECTED

\b Warns the user when the library is in use. The user will have to close applications using the library.

\b Remove the library if the file is not protected by Windows File Protection.
										
REBOOT_NOTPROTECTED

\b Remove the library on reboot when in use (required for system files).

\b Remove the library without checking for Windows File Protection.
										
NOREBOOT_NOTPROTECTED

\b Warns the user when the library is in use. The user will have to close applications using the library.

\b Remove the library without checking for Windows File Protection.


\\<b\\>file\\</b\\>

Location of the library

\S1{} Options

\R{define}{Define} any of the following before inserting the UnInstallLib macro to modify its behavior as specified.

\S2{} LIBRARY_X64

\b Uninstalls a DLL built for Windows x64.

\b \\<b\\>Warning:\\</b\\> this resets \R{setregview}{RegSetView} and file system redirection.

\S2{} LIBRARY_SHELL_EXTENSION

\b Define this before inserting UninstallLib macro to call SHChangeNotify with SHCNE_ASSOCCHANGED after unregistration. Use this to refresh the shell when uninstalling a shell extension or when changing file associations.

\S2{} LIBRARY_COM

\b Define this before inserting UninstallLib macro to call CoFreeUnusedLibraries after unregistration. Use this for unloading all unnecessary libraries from memory when uninstalling COM libraries.

\S1{} Example

\c  !insertmacro UnInstallLib REGDLL SHARED REBOOT_NOTPROTECTED $SYSDIR\dllname.dll


\H{library_vb6} Visual Basic 6 Runtimes

Add this code to your script to install and uninstall the VB6 runtimes.

The correct version of the following files should be stored in your script folder
(or modify the paths to the local files if you want to use another folder):

\b  msvbvm60.dll

\b  oleaut32.dll

\b  olepro32.dll

\b  oleaut32.dll

\b  comcat.dll

\b  asycfilt.dll

\b  stdole2.tlb

A \W{http://support.microsoft.com/default.aspx?scid=kb;en-us;290887}{Microsoft article} that explains how to obtain these files is available.

To ask the user for a reboot, if required, use the Modern UI with a Finish page or use \R{ifrebootflag}{IfRebootFlag} and make your own page or message box.

\c  !include Library.nsh
\c
\c  Var ALREADY_INSTALLED
\c
\c  Section "-Install VB6 runtimes"
\c
\c    ;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is already installed. For example:
\c
\c    IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation ;Replace MyApp.exe with your application filename
\c      StrCpy $ALREADY_INSTALLED 1
\c    new_installation:
\c
\c    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "msvbvm60.dll" "$SYSDIR\msvbvm60.dll" "$SYSDIR"
\c    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED    "oleaut32.dll" "$SYSDIR\oleaut32.dll" "$SYSDIR"
\c    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED    "olepro32.dll" "$SYSDIR\olepro32.dll" "$SYSDIR"
\c    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED    "comcat.dll"   "$SYSDIR\comcat.dll"   "$SYSDIR"
\c    !insertmacro InstallLib DLL    $ALREADY_INSTALLED REBOOT_PROTECTED    "asycfilt.dll" "$SYSDIR\asycfilt.dll" "$SYSDIR"
\c    !insertmacro InstallLib TLB    $ALREADY_INSTALLED REBOOT_PROTECTED    "stdole2.tlb"  "$SYSDIR\stdole2.tlb"  "$SYSDIR"
\c
\c  SectionEnd
\c
\c  Section "-un.Uninstall VB6 runtimes"
\c
\c    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll"
\c    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll"
\c    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll"
\c    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat.dll"
\c    !insertmacro UnInstallLib DLL    SHARED NOREMOVE "$SYSDIR\asycfilt.dll"
\c    !insertmacro UnInstallLib TLB    SHARED NOREMOVE "$SYSDIR\stdole2.tlb"
\c
\c  SectionEnd

You can use similar code to install common VB6 ActiveX controls (such as the controls for Windows Common Controls).