Problems in deleting a Folder during the uninstallation with Inno Setup

谁说胖子不能爱 提交于 2019-12-10 10:47:53

问题


I begin by saying that i am new in using Inno setup and i am sorry if this is a dumb question. I am trying to delete a folder with all it's sub-folders and files during the uninstallation of an application. The specific folder is created in My Documents when the application runes for the first time. For deleting it i am using the "Delltree" function:

    procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var Ceva: integer;
begin
  case CurUninstallStep of
    usUninstall:
      begin
        MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall is about to start.', mbInformation, MB_OK)
         end;
    usPostUninstall:
      begin
            Ceva := MsgBox('CurUninstallStepChanged:' #13#13 'Do you want to delete the folder ?.', mbConfirmation, MB_YESNO)
        if Ceva = idYES  then
        DelTree('{userdocs}\myfolder', True, True, True);           
      end;
  end;

For some reason the "{userdocs}" constant appear not to be working. If i put the exact path to the folder "DelTree('C:\Users\myuser\Documents\myfolder', True, True, True); " everything is working fine.


回答1:


When you use a constant in code, you need to use the ExpandConstant function. So your Deltree command should be:

DelTree('ExpandConstant({userdocs})\myfolder', True, True, True);

Alternatively, have you looked at the [UninstallDelete] section? It can delete a directory and files at uninstall time without the need for code.



来源:https://stackoverflow.com/questions/4722747/problems-in-deleting-a-folder-during-the-uninstallation-with-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!