root / tmp / org.txm.setups / nsis / Include / Library.nsh @ 3136
Historique | Voir | Annoter | Télécharger (21,28 ko)
1 |
# |
---|---|
2 |
# Library.nsh |
3 |
# |
4 |
# A system for the installation and uninstallation of dynamic |
5 |
# link libraries (DLL) and type libraries (TLB). Using this |
6 |
# system you can handle the complete setup with one single |
7 |
# line of code: |
8 |
# |
9 |
# * File copying |
10 |
# * File copying on reboot |
11 |
# * Version checks |
12 |
# * Registration and unregistration |
13 |
# * Registration and unregistration on reboot |
14 |
# * Shared DLL counting |
15 |
# * Windows File Protection checks |
16 |
# |
17 |
# For more information, read appendix B in the documentation. |
18 |
# |
19 |
|
20 |
!verbose push |
21 |
!verbose 3 |
22 |
|
23 |
!ifndef LIB_INCLUDED |
24 |
|
25 |
!define LIB_INCLUDED |
26 |
|
27 |
!ifndef SHCNE_ASSOCCHANGED |
28 |
!define SHCNE_ASSOCCHANGED 0x08000000 |
29 |
!endif |
30 |
!ifndef SHCNF_IDLIST |
31 |
!define SHCNF_IDLIST 0x0000 |
32 |
!endif |
33 |
|
34 |
!define REGTOOL_VERSION v3 |
35 |
!define REGTOOL_KEY NSIS.Library.RegTool.${REGTOOL_VERSION} |
36 |
|
37 |
!include LogicLib.nsh |
38 |
!include x64.nsh |
39 |
|
40 |
### GetParent macro, don't pass $1 or $2 as INTPUT or OUTPUT |
41 |
!macro __InstallLib_Helper_GetParent INPUT OUTPUT |
42 |
|
43 |
# Copied from FileFunc.nsh |
44 |
|
45 |
StrCpy ${OUTPUT} ${INPUT} |
46 |
|
47 |
Push $1 |
48 |
Push $2 |
49 |
|
50 |
StrCpy $2 ${OUTPUT} 1 -1 |
51 |
StrCmp $2 '\' 0 +3 |
52 |
StrCpy ${OUTPUT} ${OUTPUT} -1 |
53 |
goto -3 |
54 |
|
55 |
StrCpy $1 0 |
56 |
IntOp $1 $1 - 1 |
57 |
StrCpy $2 ${OUTPUT} 1 $1 |
58 |
StrCmp $2 '\' +2 |
59 |
StrCmp $2 '' 0 -3 |
60 |
StrCpy ${OUTPUT} ${OUTPUT} $1 |
61 |
|
62 |
Pop $2 |
63 |
Pop $1 |
64 |
|
65 |
!macroend |
66 |
|
67 |
### Initialize session id (GUID) |
68 |
!macro __InstallLib_Helper_InitSession |
69 |
|
70 |
!ifndef __InstallLib_SessionGUID_Defined |
71 |
|
72 |
!define __InstallLib_SessionGUID_Defined |
73 |
|
74 |
Var /GLOBAL __INSTALLLLIB_SESSIONGUID |
75 |
|
76 |
!endif |
77 |
|
78 |
!define __InstallLib_Helper_InitSession_Label "Library_${__FILE__}${__LINE__}" |
79 |
|
80 |
StrCmp $__INSTALLLLIB_SESSIONGUID '' 0 "${__InstallLib_Helper_InitSession_Label}" |
81 |
|
82 |
System::Call 'ole32::CoCreateGuid(g .s)' |
83 |
Pop $__INSTALLLLIB_SESSIONGUID |
84 |
|
85 |
"${__InstallLib_Helper_InitSession_Label}:" |
86 |
|
87 |
!undef __InstallLib_Helper_InitSession_Label |
88 |
|
89 |
!macroend |
90 |
|
91 |
### Add a RegTool entry to register after reboot |
92 |
!macro __InstallLib_Helper_AddRegToolEntry mode filename tempdir |
93 |
|
94 |
Push $R0 |
95 |
Push $R1 |
96 |
Push $R2 |
97 |
Push $R3 |
98 |
|
99 |
;------------------------ |
100 |
;Copy the parameters |
101 |
|
102 |
Push "${filename}" |
103 |
Push "${tempdir}" |
104 |
|
105 |
Pop $R2 ; temporary directory |
106 |
Pop $R1 ; file name to register |
107 |
|
108 |
;------------------------ |
109 |
;Initialize session id |
110 |
|
111 |
!insertmacro __InstallLib_Helper_InitSession |
112 |
|
113 |
;------------------------ |
114 |
;Advance counter |
115 |
|
116 |
StrCpy $R0 0 |
117 |
ReadRegDWORD $R0 HKLM "Software\${REGTOOL_KEY}\$__INSTALLLLIB_SESSIONGUID" "count" |
118 |
IntOp $R0 $R0 + 1 |
119 |
WriteRegDWORD HKLM "Software\${REGTOOL_KEY}\$__INSTALLLLIB_SESSIONGUID" "count" "$R0" |
120 |
|
121 |
;------------------------ |
122 |
;Setup RegTool |
123 |
|
124 |
!if ! /FileExists "${NSISDIR}\Bin\RegTool-${NSIS_CPU}.bin" |
125 |
!error "Missing RegTool for ${NSIS_CPU}!" |
126 |
!endif |
127 |
|
128 |
ReadRegStr $R3 HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "${REGTOOL_KEY}" |
129 |
StrCpy $R3 $R3 -4 1 |
130 |
IfFileExists $R3 +3 |
131 |
|
132 |
File /oname=$R2\${REGTOOL_KEY}.$__INSTALLLLIB_SESSIONGUID.exe "${NSISDIR}\Bin\RegTool-${NSIS_CPU}.bin" |
133 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" \ |
134 |
"${REGTOOL_KEY}" '"$R2\${REGTOOL_KEY}.$__INSTALLLLIB_SESSIONGUID.exe" /S' |
135 |
|
136 |
;------------------------ |
137 |
;Add RegTool entry |
138 |
|
139 |
WriteRegStr HKLM "Software\${REGTOOL_KEY}\$__INSTALLLLIB_SESSIONGUID" "$R0.file" "$R1" |
140 |
WriteRegStr HKLM "Software\${REGTOOL_KEY}\$__INSTALLLLIB_SESSIONGUID" "$R0.mode" "${mode}" |
141 |
|
142 |
Pop $R3 |
143 |
Pop $R2 |
144 |
Pop $R1 |
145 |
Pop $R0 |
146 |
|
147 |
!macroend |
148 |
|
149 |
!macro __InstallLib_Helper_CmpPackedVer64 oldhi oldlo newhi newlo jeq jle jgt |
150 |
|
151 |
IntCmpU ${oldhi} ${newhi} "0" "${jle}" "${jgt}" |
152 |
IntCmpU ${oldlo} ${newlo} "${jeq}" "${jle}" "${jgt}" |
153 |
|
154 |
!macroend |
155 |
|
156 |
### Get library version |
157 |
!macro __InstallLib_Helper_GetVersion TYPE FILE |
158 |
|
159 |
!if "${TYPE}" == "D" |
160 |
!getdllversion /NoErrors /Packed "${FILE}" LIBRARY_VERSION_ |
161 |
!else if "${TYPE}" == "T" |
162 |
!gettlbversion /NoErrors /Packed "${FILE}" LIBRARY_VERSION_ |
163 |
!endif |
164 |
|
165 |
; Emulate the old LibraryLocal defines |
166 |
!ifndef LIBRARY_VERSION_HIGH |
167 |
!define LIBRARY_VERSION_FILENOTFOUND |
168 |
!else if "${LIBRARY_VERSION_HIGH}" == "" |
169 |
!define LIBRARY_VERSION_NONE |
170 |
!undef LIBRARY_VERSION_HIGH |
171 |
!undef LIBRARY_VERSION_LOW |
172 |
!endif |
173 |
|
174 |
!macroend |
175 |
|
176 |
### Install library |
177 |
!macro InstallLib libtype shared install localfile destfile tempbasedir |
178 |
|
179 |
!verbose push |
180 |
!verbose 3 |
181 |
|
182 |
Push $R0 |
183 |
Push $R1 |
184 |
Push $R2 |
185 |
Push $R3 |
186 |
Push $R4 |
187 |
Push $R5 |
188 |
|
189 |
;------------------------ |
190 |
;Define |
191 |
|
192 |
!define INSTALLLIB_UNIQUE "${__FILE__}${__LINE__}" |
193 |
|
194 |
!define INSTALLLIB_LIBTYPE_${libtype} |
195 |
!define INSTALLLIB_LIBTYPE_SET INSTALLLIB_LIBTYPE_${libtype} |
196 |
!define INSTALLLIB_SHARED_${shared} |
197 |
!define INSTALLLIB_SHARED_SET INSTALLLIB_SHARED_${shared} |
198 |
!define INSTALLLIB_INSTALL_${install} |
199 |
!define INSTALLLIB_INSTALL_SET INSTALLLIB_INSTALL_${install} |
200 |
|
201 |
;------------------------ |
202 |
;Validate |
203 |
|
204 |
!ifndef INSTALLLIB_LIBTYPE_DLL & INSTALLLIB_LIBTYPE_REGDLL & INSTALLLIB_LIBTYPE_TLB & \ |
205 |
INSTALLLIB_LIBTYPE_REGDLLTLB & INSTALLLIB_LIBTYPE_REGEXE |
206 |
!error "InstallLib: Incorrect setting for parameter: libtype" |
207 |
!endif |
208 |
|
209 |
!ifndef INSTALLLIB_INSTALL_REBOOT_PROTECTED & INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED & \ |
210 |
INSTALLLIB_INSTALL_NOREBOOT_PROTECTED & INSTALLLIB_INSTALL_NOREBOOT_NOTPROTECTED |
211 |
!error "InstallLib: Incorrect setting for parameter: install" |
212 |
!endif |
213 |
|
214 |
;------------------------ |
215 |
;x64 settings |
216 |
|
217 |
!ifdef LIBRARY_X64 |
218 |
|
219 |
${DisableX64FSRedirection} |
220 |
|
221 |
!endif |
222 |
|
223 |
;------------------------ |
224 |
;Copy the parameters used on run-time to a variable |
225 |
;This allows the usage of variables as parameter |
226 |
|
227 |
StrCpy $R4 "${destfile}" |
228 |
StrCpy $R5 "${tempbasedir}" |
229 |
|
230 |
;------------------------ |
231 |
;Shared library count |
232 |
|
233 |
!ifndef INSTALLLIB_SHARED_NOTSHARED |
234 |
|
235 |
StrCmp ${shared} "" 0 "installlib.noshareddllincrease_${INSTALLLIB_UNIQUE}" |
236 |
|
237 |
!ifdef LIBRARY_X64 |
238 |
|
239 |
SetRegView 64 |
240 |
|
241 |
!endif |
242 |
|
243 |
ReadRegDword $R0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R4 |
244 |
ClearErrors |
245 |
IntOp $R0 $R0 + 1 |
246 |
WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R4 $R0 |
247 |
|
248 |
!ifdef LIBRARY_X64 |
249 |
|
250 |
SetRegView lastused |
251 |
|
252 |
!endif |
253 |
|
254 |
"installlib.noshareddllincrease_${INSTALLLIB_UNIQUE}:" |
255 |
|
256 |
!endif |
257 |
|
258 |
;------------------------ |
259 |
;Check Windows File Protection |
260 |
|
261 |
!ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_NOREBOOT_PROTECTED |
262 |
|
263 |
!define LIBRARY_DEFINE_DONE_LABEL |
264 |
|
265 |
System::Call "sfc::SfcIsFileProtected(i 0, w R4) i.R0" |
266 |
|
267 |
StrCmp $R0 "error" "installlib.notprotected_${INSTALLLIB_UNIQUE}" |
268 |
StrCmp $R0 "0" "installlib.notprotected_${INSTALLLIB_UNIQUE}" |
269 |
|
270 |
Goto "installlib.done_${INSTALLLIB_UNIQUE}" |
271 |
|
272 |
"installlib.notprotected_${INSTALLLIB_UNIQUE}:" |
273 |
|
274 |
!endif |
275 |
|
276 |
;------------------------ |
277 |
;Check file |
278 |
|
279 |
IfFileExists $R4 0 "installlib.copy_${INSTALLLIB_UNIQUE}" |
280 |
|
281 |
;------------------------ |
282 |
;Get version information |
283 |
|
284 |
!ifndef LIBRARY_IGNORE_VERSION |
285 |
|
286 |
!insertmacro __InstallLib_Helper_GetVersion D "${LOCALFILE}" |
287 |
|
288 |
!ifdef LIBRARY_VERSION_FILENOTFOUND |
289 |
!error "InstallLib: The library ${LOCALFILE} could not be found." |
290 |
!endif |
291 |
|
292 |
!ifndef LIBRARY_VERSION_NONE |
293 |
|
294 |
!define LIBRARY_DEFINE_UPGRADE_LABEL |
295 |
!define LIBRARY_DEFINE_REGISTER_LABEL |
296 |
|
297 |
StrCpy $R0 ${LIBRARY_VERSION_HIGH} |
298 |
StrCpy $R1 ${LIBRARY_VERSION_LOW} |
299 |
|
300 |
GetDLLVersion $R4 $R2 $R3 |
301 |
|
302 |
!undef LIBRARY_VERSION_HIGH |
303 |
!undef LIBRARY_VERSION_LOW |
304 |
|
305 |
!ifndef INSTALLLIB_LIBTYPE_TLB & INSTALLLIB_LIBTYPE_REGDLLTLB |
306 |
|
307 |
!ifdef LIBRARY_INSTALL_EQUAL_VERSION |
308 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 "installlib.upgrade_${INSTALLLIB_UNIQUE}" \ |
309 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
310 |
!else |
311 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 "installlib.register_${INSTALLLIB_UNIQUE}" \ |
312 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
313 |
!endif |
314 |
|
315 |
!else |
316 |
|
317 |
!insertmacro __InstallLib_Helper_GetVersion T "${LOCALFILE}" |
318 |
|
319 |
!ifdef LIBRARY_VERSION_FILENOTFOUND |
320 |
!error "InstallLib: The library ${LOCALFILE} could not be found." |
321 |
!endif |
322 |
|
323 |
!ifndef LIBRARY_VERSION_NONE |
324 |
|
325 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 0 \ |
326 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
327 |
|
328 |
!else |
329 |
|
330 |
!ifdef LIBRARY_INSTALL_EQUAL_VERSION |
331 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 "installlib.upgrade_${INSTALLLIB_UNIQUE}" \ |
332 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
333 |
!else |
334 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 "installlib.register_${INSTALLLIB_UNIQUE}" \ |
335 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
336 |
!endif |
337 |
|
338 |
!endif |
339 |
|
340 |
!endif |
341 |
|
342 |
!else |
343 |
|
344 |
!undef LIBRARY_VERSION_NONE |
345 |
|
346 |
!ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB |
347 |
|
348 |
!insertmacro __InstallLib_Helper_GetVersion T "${LOCALFILE}" |
349 |
|
350 |
!endif |
351 |
|
352 |
!endif |
353 |
|
354 |
!ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB |
355 |
|
356 |
!ifndef LIBRARY_VERSION_NONE |
357 |
|
358 |
!ifndef LIBRARY_DEFINE_UPGRADE_LABEL |
359 |
|
360 |
!define LIBRARY_DEFINE_UPGRADE_LABEL |
361 |
|
362 |
!endif |
363 |
|
364 |
!ifndef LIBRARY_DEFINE_REGISTER_LABEL |
365 |
|
366 |
!define LIBRARY_DEFINE_REGISTER_LABEL |
367 |
|
368 |
!endif |
369 |
|
370 |
StrCpy $R0 ${LIBRARY_VERSION_HIGH} |
371 |
StrCpy $R1 ${LIBRARY_VERSION_LOW} |
372 |
|
373 |
TypeLib::GetLibVersion $R4 |
374 |
Pop $R3 |
375 |
Pop $R2 |
376 |
|
377 |
!ifdef LIBRARY_INSTALL_EQUAL_VERSION |
378 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 "installlib.upgrade_${INSTALLLIB_UNIQUE}" \ |
379 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
380 |
!else |
381 |
!insertmacro __InstallLib_Helper_CmpPackedVer64 $R0 $R1 $R2 $R3 "installlib.register_${INSTALLLIB_UNIQUE}" \ |
382 |
"installlib.register_${INSTALLLIB_UNIQUE}" "installlib.upgrade_${INSTALLLIB_UNIQUE}" |
383 |
!endif |
384 |
|
385 |
!undef LIBRARY_VERSION_HIGH |
386 |
!undef LIBRARY_VERSION_LOW |
387 |
|
388 |
!else |
389 |
|
390 |
!undef LIBRARY_VERSION_NONE |
391 |
|
392 |
!endif |
393 |
|
394 |
!endif |
395 |
|
396 |
!endif ;~LIBRARY_IGNORE_VERSION |
397 |
|
398 |
;------------------------ |
399 |
;Upgrade |
400 |
|
401 |
!ifdef LIBRARY_DEFINE_UPGRADE_LABEL |
402 |
|
403 |
!undef LIBRARY_DEFINE_UPGRADE_LABEL |
404 |
|
405 |
"installlib.upgrade_${INSTALLLIB_UNIQUE}:" |
406 |
|
407 |
!endif |
408 |
|
409 |
;------------------------ |
410 |
;Copy |
411 |
|
412 |
!ifdef INSTALLLIB_INSTALL_NOREBOOT_PROTECTED | INSTALLLIB_INSTALL_NOREBOOT_NOTPROTECTED |
413 |
|
414 |
"installlib.copy_${INSTALLLIB_UNIQUE}:" |
415 |
|
416 |
StrCpy $R0 $R4 |
417 |
Call ":installlib.file_${INSTALLLIB_UNIQUE}" |
418 |
|
419 |
!else |
420 |
|
421 |
!ifndef LIBRARY_DEFINE_REGISTER_LABEL |
422 |
|
423 |
!define LIBRARY_DEFINE_REGISTER_LABEL |
424 |
|
425 |
!endif |
426 |
|
427 |
!ifndef LIBRARY_DEFINE_DONE_LABEL |
428 |
|
429 |
!define LIBRARY_DEFINE_DONE_LABEL |
430 |
|
431 |
!endif |
432 |
|
433 |
ClearErrors |
434 |
|
435 |
StrCpy $R0 $R4 |
436 |
Call ":installlib.file_${INSTALLLIB_UNIQUE}" |
437 |
|
438 |
IfErrors 0 "installlib.register_${INSTALLLIB_UNIQUE}" |
439 |
|
440 |
SetOverwrite lastused |
441 |
|
442 |
;------------------------ |
443 |
;Copy on reboot |
444 |
|
445 |
GetTempFileName $R0 $R5 |
446 |
Call ":installlib.file_${INSTALLLIB_UNIQUE}" |
447 |
Rename /REBOOTOK $R0 $R4 |
448 |
|
449 |
;------------------------ |
450 |
;Register on reboot |
451 |
|
452 |
Call ":installlib.regonreboot_${INSTALLLIB_UNIQUE}" |
453 |
|
454 |
Goto "installlib.done_${INSTALLLIB_UNIQUE}" |
455 |
|
456 |
"installlib.copy_${INSTALLLIB_UNIQUE}:" |
457 |
StrCpy $R0 $R4 |
458 |
Call ":installlib.file_${INSTALLLIB_UNIQUE}" |
459 |
|
460 |
!endif |
461 |
|
462 |
;------------------------ |
463 |
;Register |
464 |
|
465 |
!ifdef LIBRARY_DEFINE_REGISTER_LABEL |
466 |
|
467 |
!undef LIBRARY_DEFINE_REGISTER_LABEL |
468 |
|
469 |
"installlib.register_${INSTALLLIB_UNIQUE}:" |
470 |
|
471 |
!endif |
472 |
|
473 |
!ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB | INSTALLLIB_LIBTYPE_REGEXE |
474 |
|
475 |
!ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED |
476 |
|
477 |
IfRebootFlag 0 "installlib.regnoreboot_${INSTALLLIB_UNIQUE}" |
478 |
|
479 |
Call ":installlib.regonreboot_${INSTALLLIB_UNIQUE}" |
480 |
|
481 |
Goto "installlib.registerfinish_${INSTALLLIB_UNIQUE}" |
482 |
|
483 |
"installlib.regnoreboot_${INSTALLLIB_UNIQUE}:" |
484 |
|
485 |
!endif |
486 |
|
487 |
!ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB |
488 |
|
489 |
TypeLib::Register $R4 |
490 |
|
491 |
!endif |
492 |
|
493 |
!ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_REGDLLTLB |
494 |
|
495 |
!ifndef LIBRARY_X64 |
496 |
|
497 |
RegDll $R4 |
498 |
|
499 |
!else |
500 |
|
501 |
ExecWait '"$SYSDIR\regsvr32.exe" /s "$R4"' |
502 |
|
503 |
!endif |
504 |
|
505 |
!endif |
506 |
|
507 |
!ifdef INSTALLLIB_LIBTYPE_REGEXE |
508 |
|
509 |
ExecWait '"$R4" /regserver' |
510 |
|
511 |
!endif |
512 |
|
513 |
!ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED |
514 |
|
515 |
"installlib.registerfinish_${INSTALLLIB_UNIQUE}:" |
516 |
|
517 |
!endif |
518 |
|
519 |
!endif |
520 |
|
521 |
!ifdef LIBRARY_SHELL_EXTENSION |
522 |
|
523 |
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' |
524 |
|
525 |
!endif |
526 |
|
527 |
!ifdef LIBRARY_COM |
528 |
|
529 |
System::Call 'Ole32::CoFreeUnusedLibraries()' |
530 |
|
531 |
!endif |
532 |
|
533 |
;------------------------ |
534 |
;Done |
535 |
|
536 |
!ifdef LIBRARY_DEFINE_DONE_LABEL |
537 |
|
538 |
!undef LIBRARY_DEFINE_DONE_LABEL |
539 |
|
540 |
"installlib.done_${INSTALLLIB_UNIQUE}:" |
541 |
|
542 |
!endif |
543 |
|
544 |
Pop $R5 |
545 |
Pop $R4 |
546 |
Pop $R3 |
547 |
Pop $R2 |
548 |
Pop $R1 |
549 |
Pop $R0 |
550 |
|
551 |
;------------------------ |
552 |
;End |
553 |
|
554 |
Goto "installlib.end_${INSTALLLIB_UNIQUE}" |
555 |
|
556 |
;------------------------ |
557 |
;Extract |
558 |
|
559 |
!ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED |
560 |
|
561 |
SetOverwrite try |
562 |
|
563 |
!else |
564 |
|
565 |
SetOverwrite on |
566 |
|
567 |
!endif |
568 |
|
569 |
"installlib.file_${INSTALLLIB_UNIQUE}:" |
570 |
SetFileAttributes $R0 FILE_ATTRIBUTE_NORMAL |
571 |
ClearErrors |
572 |
File /oname=$R0 "${LOCALFILE}" |
573 |
Return |
574 |
|
575 |
SetOverwrite lastused |
576 |
|
577 |
;------------------------ |
578 |
;Register on reboot |
579 |
|
580 |
!ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED |
581 |
|
582 |
"installlib.regonreboot_${INSTALLLIB_UNIQUE}:" |
583 |
|
584 |
!ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_REGDLLTLB |
585 |
!ifndef LIBRARY_X64 |
586 |
!insertmacro __InstallLib_Helper_AddRegToolEntry 'D' "$R4" "$R5" |
587 |
!else |
588 |
!insertmacro __InstallLib_Helper_AddRegToolEntry 'DX' "$R4" "$R5" |
589 |
!endif |
590 |
!endif |
591 |
|
592 |
!ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB |
593 |
!insertmacro __InstallLib_Helper_AddRegToolEntry 'T' "$R4" "$R5" |
594 |
!endif |
595 |
|
596 |
!ifdef INSTALLLIB_LIBTYPE_REGEXE |
597 |
!insertmacro __InstallLib_Helper_AddRegToolEntry 'E' "$R4" "$R5" |
598 |
!endif |
599 |
|
600 |
Return |
601 |
|
602 |
!endif |
603 |
|
604 |
;------------------------ |
605 |
;End label |
606 |
|
607 |
"installlib.end_${INSTALLLIB_UNIQUE}:" |
608 |
|
609 |
!ifdef LIBRARY_X64 |
610 |
|
611 |
${EnableX64FSRedirection} |
612 |
|
613 |
!endif |
614 |
|
615 |
;------------------------ |
616 |
;Undefine |
617 |
|
618 |
!undef INSTALLLIB_UNIQUE |
619 |
|
620 |
!undef ${INSTALLLIB_LIBTYPE_SET} |
621 |
!undef INSTALLLIB_LIBTYPE_SET |
622 |
!undef ${INSTALLLIB_SHARED_SET} |
623 |
!undef INSTALLLIB_SHARED_SET |
624 |
!undef ${INSTALLLIB_INSTALL_SET} |
625 |
!undef INSTALLLIB_INSTALL_SET |
626 |
|
627 |
!verbose pop |
628 |
|
629 |
!macroend |
630 |
|
631 |
### Uninstall library |
632 |
!macro UnInstallLib libtype shared uninstall file |
633 |
|
634 |
!verbose push |
635 |
!verbose 3 |
636 |
|
637 |
Push $R0 |
638 |
Push $R1 |
639 |
|
640 |
;------------------------ |
641 |
;Define |
642 |
|
643 |
!define UNINSTALLLIB_UNIQUE "${__FILE__}${__LINE__}" |
644 |
|
645 |
!define UNINSTALLLIB_LIBTYPE_${libtype} |
646 |
!define UNINSTALLLIB_LIBTYPE_SET UNINSTALLLIB_LIBTYPE_${libtype} |
647 |
!define UNINSTALLLIB_SHARED_${shared} |
648 |
!define UNINSTALLLIB_SHARED_SET UNINSTALLLIB_SHARED_${shared} |
649 |
!define UNINSTALLLIB_UNINSTALL_${uninstall} |
650 |
!define UNINSTALLLIB_UNINSTALL_SET UNINSTALLLIB_UNINSTALL_${uninstall} |
651 |
|
652 |
;------------------------ |
653 |
;Validate |
654 |
|
655 |
!ifndef UNINSTALLLIB_LIBTYPE_DLL & UNINSTALLLIB_LIBTYPE_REGDLL & UNINSTALLLIB_LIBTYPE_TLB & \ |
656 |
UNINSTALLLIB_LIBTYPE_REGDLLTLB & UNINSTALLLIB_LIBTYPE_REGEXE |
657 |
!error "UnInstallLib: Incorrect setting for parameter: libtype" |
658 |
!endif |
659 |
|
660 |
!ifndef UNINSTALLLIB_SHARED_NOTSHARED & UNINSTALLLIB_SHARED_SHARED |
661 |
!error "UnInstallLib: Incorrect setting for parameter: shared" |
662 |
!endif |
663 |
|
664 |
!ifndef UNINSTALLLIB_UNINSTALL_NOREMOVE & UNINSTALLLIB_UNINSTALL_REBOOT_PROTECTED & \ |
665 |
UNINSTALLLIB_UNINSTALL_REBOOT_NOTPROTECTED & UNINSTALLLIB_UNINSTALL_NOREBOOT_PROTECTED & \ |
666 |
UNINSTALLLIB_UNINSTALL_NOREBOOT_NOTPROTECTED |
667 |
!error "UnInstallLib: Incorrect setting for parameter: uninstall" |
668 |
!endif |
669 |
|
670 |
;------------------------ |
671 |
;x64 settings |
672 |
|
673 |
!ifdef LIBRARY_X64 |
674 |
|
675 |
${DisableX64FSRedirection} |
676 |
|
677 |
!endif |
678 |
|
679 |
;------------------------ |
680 |
;Copy the parameters used on run-time to a variable |
681 |
;This allows the usage of variables as parameter |
682 |
|
683 |
StrCpy $R1 "${file}" |
684 |
|
685 |
;------------------------ |
686 |
;Shared library count |
687 |
|
688 |
!ifdef UNINSTALLLIB_SHARED_SHARED |
689 |
|
690 |
!define UNINSTALLLIB_DONE_LABEL |
691 |
|
692 |
!ifdef LIBRARY_X64 |
693 |
|
694 |
SetRegView 64 |
695 |
|
696 |
!endif |
697 |
|
698 |
ReadRegDword $R0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 |
699 |
StrCmp $R0 "" "uninstalllib.shareddlldone_${UNINSTALLLIB_UNIQUE}" |
700 |
|
701 |
IntOp $R0 $R0 - 1 |
702 |
IntCmp $R0 0 "uninstalllib.shareddllremove_${UNINSTALLLIB_UNIQUE}" \ |
703 |
"uninstalllib.shareddllremove_${UNINSTALLLIB_UNIQUE}" "uninstalllib.shareddllinuse_${UNINSTALLLIB_UNIQUE}" |
704 |
|
705 |
"uninstalllib.shareddllremove_${UNINSTALLLIB_UNIQUE}:" |
706 |
DeleteRegValue HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 |
707 |
!ifndef UNINSTALLLIB_SHARED_SHAREDNOREMOVE |
708 |
Goto "uninstalllib.shareddlldone_${UNINSTALLLIB_UNIQUE}" |
709 |
!endif |
710 |
|
711 |
"uninstalllib.shareddllinuse_${UNINSTALLLIB_UNIQUE}:" |
712 |
WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 $R0 |
713 |
|
714 |
!ifdef LIBRARY_X64 |
715 |
|
716 |
SetRegView lastused |
717 |
|
718 |
!endif |
719 |
|
720 |
Goto "uninstalllib.done_${UNINSTALLLIB_UNIQUE}" |
721 |
|
722 |
"uninstalllib.shareddlldone_${UNINSTALLLIB_UNIQUE}:" |
723 |
|
724 |
!ifdef LIBRARY_X64 |
725 |
|
726 |
SetRegView lastused |
727 |
|
728 |
!endif |
729 |
|
730 |
!endif |
731 |
|
732 |
;------------------------ |
733 |
;Remove |
734 |
|
735 |
!ifndef UNINSTALLLIB_UNINSTALL_NOREMOVE |
736 |
|
737 |
;------------------------ |
738 |
;Check Windows File Protection |
739 |
|
740 |
!ifdef UNINSTALLLIB_UNINSTALL_REBOOT_PROTECTED | UNINSTALLLIB_UNINSTALL_NOREBOOT_PROTECTED |
741 |
|
742 |
!ifndef UNINSTALLLIB_DONE_LABEL |
743 |
|
744 |
!define UNINSTALLLIB_DONE_LABEL |
745 |
|
746 |
!endif |
747 |
|
748 |
System::Call "sfc::SfcIsFileProtected(i 0, w $R1) i.R0" |
749 |
|
750 |
StrCmp $R0 "error" "uninstalllib.notprotected_${UNINSTALLLIB_UNIQUE}" |
751 |
StrCmp $R0 "0" "uninstalllib.notprotected_${UNINSTALLLIB_UNIQUE}" |
752 |
|
753 |
Goto "uninstalllib.done_${UNINSTALLLIB_UNIQUE}" |
754 |
|
755 |
"uninstalllib.notprotected_${UNINSTALLLIB_UNIQUE}:" |
756 |
|
757 |
!endif |
758 |
|
759 |
;------------------------ |
760 |
;Unregister |
761 |
|
762 |
!ifdef UNINSTALLLIB_LIBTYPE_REGDLL | UNINSTALLLIB_LIBTYPE_REGDLLTLB |
763 |
|
764 |
!ifndef LIBRARY_X64 |
765 |
|
766 |
UnRegDLL $R1 |
767 |
|
768 |
!else |
769 |
|
770 |
ExecWait '"$SYSDIR\regsvr32.exe" /s /u "$R1"' |
771 |
|
772 |
!endif |
773 |
|
774 |
!endif |
775 |
|
776 |
!ifdef UNINSTALLLIB_LIBTYPE_REGEXE |
777 |
|
778 |
ExecWait '"$R1" /unregserver' |
779 |
|
780 |
!endif |
781 |
|
782 |
!ifdef UNINSTALLLIB_LIBTYPE_TLB | UNINSTALLLIB_LIBTYPE_REGDLLTLB |
783 |
|
784 |
TypeLib::UnRegister $R1 |
785 |
|
786 |
!endif |
787 |
|
788 |
!ifdef LIBRARY_SHELL_EXTENSION |
789 |
|
790 |
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' |
791 |
|
792 |
!endif |
793 |
|
794 |
!ifdef LIBRARY_COM |
795 |
|
796 |
System::Call 'Ole32::CoFreeUnusedLibraries()' |
797 |
|
798 |
!endif |
799 |
|
800 |
;------------------------ |
801 |
;Delete |
802 |
|
803 |
Delete $R1 |
804 |
|
805 |
!ifdef UNINSTALLLIB_UNINSTALL_REBOOT_PROTECTED | UNINSTALLLIB_UNINSTALL_REBOOT_NOTPROTECTED |
806 |
|
807 |
${If} ${FileExists} $R1 |
808 |
# File is in use, can't just delete. |
809 |
# Move file to another location before using Delete /REBOOTOK. This way, if |
810 |
# the user installs a new version of the DLL, it won't be deleted after |
811 |
# reboot. See bug #1097642 for more information on this. |
812 |
|
813 |
# Try moving to $TEMP. |
814 |
GetTempFileName $R0 |
815 |
Delete $R0 |
816 |
Rename $R1 $R0 |
817 |
|
818 |
${If} ${FileExists} $R1 |
819 |
# Still here, delete temporary file, in case the file was copied |
820 |
# and not deleted. This happens when moving from network drives, |
821 |
# for example. |
822 |
Delete $R0 |
823 |
|
824 |
# Try moving to directory containing the file. |
825 |
!insertmacro __InstallLib_Helper_GetParent $R1 $R0 |
826 |
GetTempFileName $R0 $R0 |
827 |
Delete $R0 |
828 |
Rename $R1 $R0 |
829 |
|
830 |
${If} ${FileExists} $R1 |
831 |
# Still here, delete temporary file. |
832 |
Delete $R0 |
833 |
|
834 |
# Give up moving, simply Delete /REBOOTOK the file. |
835 |
StrCpy $R0 $R1 |
836 |
${EndIf} |
837 |
${EndIf} |
838 |
|
839 |
# Delete the moved file. |
840 |
Delete /REBOOTOK $R0 |
841 |
${EndIf} |
842 |
|
843 |
!endif |
844 |
|
845 |
!endif |
846 |
|
847 |
;------------------------ |
848 |
;Done |
849 |
|
850 |
!ifdef UNINSTALLLIB_DONE_LABEL |
851 |
|
852 |
!undef UNINSTALLLIB_DONE_LABEL |
853 |
|
854 |
"uninstalllib.done_${UNINSTALLLIB_UNIQUE}:" |
855 |
|
856 |
!endif |
857 |
|
858 |
!ifdef LIBRARY_X64 |
859 |
|
860 |
${EnableX64FSRedirection} |
861 |
|
862 |
!endif |
863 |
|
864 |
Pop $R1 |
865 |
Pop $R0 |
866 |
|
867 |
;------------------------ |
868 |
;Undefine |
869 |
|
870 |
!undef UNINSTALLLIB_UNIQUE |
871 |
|
872 |
!undef ${UNINSTALLLIB_LIBTYPE_SET} |
873 |
!undef UNINSTALLLIB_LIBTYPE_SET |
874 |
!undef ${UNINSTALLLIB_SHARED_SET} |
875 |
!undef UNINSTALLLIB_SHARED_SET |
876 |
!undef ${UNINSTALLLIB_UNINSTALL_SET} |
877 |
!undef UNINSTALLLIB_UNINSTALL_SET |
878 |
|
879 |
!verbose pop |
880 |
|
881 |
!macroend |
882 |
|
883 |
!endif |
884 |
|
885 |
!verbose pop |