Can't delete the folder created in My Documents with Inno Setup

倾然丶 夕夏残阳落幕 提交于 2019-12-01 08:24:09

问题


I have tried to use the program described here Problems in deleting a Folder during the uninstalation with Inno Setup

after the answers were posted but for some unknown reason to me that code part isn't doing anything. May be related to windows version or if it's on 32 or 64 bit?

Here's the code used by me:

procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
mres : integer;
begin
 case CurUninstallStep of
 usPostUninstall:
 begin
mres := MsgBox('Do you want to delete saved games?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
 if mres = IDYES then
   DelTree('ExpandConstant({userdocs}\SpellForce2)', True, True, True);
    end;  
  end;
end;

Any idea that could be useful to me?

Thanks in advance! :)


回答1:


You are trying to delete a folder named 'ExpandConstant({userdocs}\SpellForce2)' (literally), just remove the ' character to the ExpandConstant call (it is a call to a sub-routine).

procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox('Do you want to delete saved games?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mres = IDYES then
          DelTree(ExpandConstant('{userdocs}\SpellForce2'), True, True, True);
      end;  
  end;
end;



回答2:


You cannot do

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

Of course, this should read

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


来源:https://stackoverflow.com/questions/4829089/cant-delete-the-folder-created-in-my-documents-with-inno-setup

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