Archive: Can I use name one of function for the Installer and the Uninstaller ?


Can I use name one of function for the Installer and the Uninstaller ?
  I wrote one function and Function name's DeleteFontKey. This Function run good in Section Installer but it's not run in Uninstaller. It's warning error: Call must be used with function names starting with "un." in the uninstall section. Usage: Call function_name | [:label_name] Error in script "C:\Program Files\NSIS\Examples\Setup1.5_final.nsi" on line 272 -- aborting creation process. Can i use only one function for Installer and Uninstaller ? This is my program structure:

.....
Function DeleteFontKey
..... command
FunctionEnd

Section
.... Command
Call DeleteFontKey
.... Command
SectionEnd

Section Uninstall
.... command
Call DeleteFontKey # This is line error 272 -- aborting creation process
.... command
SectionEnd

Can i use only one name function for Installer and Uninstaller ? How can i set name for function ? I don't want to write two function have same one content but It's two name different. Help me ?


Re: Can I use name one of function for the Installer and the Uninstaller ?
 

Originally posted by dong
Can i use only one function for Installer and Uninstaller ?
Yes, you can.
You have to write little macro, that will do it for you.
It shoud like this:

!macro SharedFunction un


>Function ${un}DeleteFontKey

>; Your function code...

>FunctionEnd

>!macroend

>; Insert function as an installer and uninstaller function.
!insertmacro SharedFunction ""
>!insertmacro SharedFunction "un."
And in sections code you call that function like that:
In Installer code:

Call DeleteFontKey 

>
In uninstaller code:

Call un.DeleteFontKey 

>
Regards,
-Pawel

Thank you wrote to me.