【问题标题】:Problems in deleting a Folder during the uninstallation with Inno Setup使用 Inno Setup 卸载期间删除文件夹的问题
【发布时间】:2011-01-18 10:02:59
【问题描述】:

我首先说我是使用 Inno 设置的新手,如果这是一个愚蠢的问题,我很抱歉。 我正在尝试在卸载应用程序期间删除包含所有子文件夹和文件的文件夹。应用程序第一次运行时,将在“我的文档”中创建特定文件夹。为了删除它,我使用“Delltree”功能:

    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;

由于某种原因,“{userdocs}”常量似乎不起作用。如果我将确切路径放入文件夹“DelTree('C:\Users\myuser\Documents\myfolder', True, True, True); ”,一切正常。

【问题讨论】:

    标签: inno-setup uninstallation


    【解决方案1】:

    在代码中使用常量时,需要使用 ExpandConstant 函数。所以你的 Deltree 命令应该是:

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

    或者,您是否查看过 [UninstallDelete] 部分?它可以在卸载时删除目录和文件,无需代码。

    【讨论】:

    • 非常感谢。 DelTree('ExpandConstant({userdocs})\myfolder', True, True, True);完美地工作。我在发布问题之前尝试了 [UninstallDelete] 部分并且它有效,但我需要用户选择是否要删除特定文件夹。我没有找到使用 [UninstallDelete] 的方法
    • 对我来说,它的语法如下: DelTree(ExpandConstant('{userdocs}') +'\myfolder', True, True, True);
    猜你喜欢
    • 1970-01-01
    • 2017-08-15
    • 2020-09-09
    • 1970-01-01
    • 2016-02-19
    • 2014-07-08
    • 2020-09-09
    • 2021-04-10
    相关资源
    最近更新 更多