Search

Monday, August 22, 2011

Innosetup delete files during uninstall procedure

how to delete files created during runtime while uninstalling the application this is the question came to my mind when one of the app was using old configuration data which was not deleted during un-installation after a brief search on Google i came across the sample procedure on stack overflow forums that worked like a charm so thought of putting it here for my future reference and for people who are searching for this piece of code.

to achieve this and prompt user whether to delete the application generated files during run time we have to create a routine "CurUninstallStepChanged" and write the action during this event see the below code

procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);

var
mres : integer;
begin
case CurUninstallStep of
usPostUninstall:
begin
mres := MsgBox('Do you want to delete saved files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
if mres = IDYES then

// use below code to Delete files from App data in documents and settings
DelTree(ExpandConstant('{userappdata}\yourappfoldername'), True, True, True);

// use below code to Delete files from installation folder
DelTree(ExpandConstant('{app}'), True, True, True);

end;
end;
end;

for a complete path structure API's / Codes visit this LINK which i posted long back.

above example shows on how to delete files in installation and application data folder the above method delete all the files and entire application folder, you can even make your own function call and write custom actions to be performed

1 comments:

Green Mountain Realty said...

Really Good Information

Post a Comment

Other Interesting Articles



Related Article Widget by Yogith

Search Powered by Google