Archive: How to add functions to installer AND uninstaller?


How to add functions to installer AND uninstaller?
The are some lines of code which should be executed both in Installer and Uninstaller functions (.onInit and un.onInit).

How to write code in a way that I can use it in these two?


the easy way, just use a macro
!macro MyCode
#code here
!macroend

and just use !insertmacro MyCode in both .onInit and un.onInit

or if you want actual functions (you need recursion, or the code is used several times)

!macro MakeMyFunc un
Function ${un}MyFunc
#code here
FunctionEnd
!macroend

!insertmacro MakeMyFunc ""
!insertmacro MakeMyFunc "un."

now you can call MyFunc in both installer and uninstaller