Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / Library.nsh @ 1105

Historique | Voir | Annoter | Télécharger (20,31 ko)

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