如何配置Inno Setup卸载所有内容? [英] How to configure Inno Setup to uninstall everything?

查看:376
本文介绍了如何配置Inno Setup卸载所有内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Inno Setup的新手.困扰一个问题〜如何配置卸载程序以删除应用程序创建的所有文件,文件夹,子文件夹,甚至新文件/文件夹等(换句话说,是100%删除了应用程序和相关文件).

我在这里和他们的论坛上闲逛,然后空了出来.谁能指出我有关如何执行此操作的文档,常见问题解答等?

更新

感谢到目前为止的所有反馈(非常棒).因此,看起来我可以使用卸载部分中的{app} *.*指令删除所有内容.看起来每个人都在建议这样做. 现在问题变成了(我想知道这是否应该是一个全新的问题),在卸载过程中是否有一种方法可以让用户询问您是否要删除与此项目相关联的所有项目文件?应用?'如果他们回答是",则运行卸载{app} *.*件?

谢谢-

解决方案

您应该已经提出了一个全新的问题,但是我也会在这里回答您更新的问题.请查看Inno设置文档中的"Pascal脚本:卸载代码" 部分.

举例说明如何在卸载过程中有条件地删除数据文件:

[Code]

procedure DeleteBitmaps(ADirName: string);
var
  FindRec: TFindRec;
begin
  if FindFirst(ADirName + '\*.*', FindRec) then begin
    try
      repeat
        if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin
          if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin
            DeleteBitmaps(ADirName + '\' + FindRec.Name);
            RemoveDir(ADirName + '\' + FindRec.Name);
          end;
        end else if Pos('.bmp', AnsiLowerCase(FindRec.Name)) > 0 then
          DeleteFile(ADirName + '\' + FindRec.Name);
      until not FindNext(FindRec);
    finally
      FindClose(FindRec);
    end;
  end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then begin
    if MsgBox('Do you want to delete all data files?', mbConfirmation,
        MB_YESNO) = IDYES 
    then begin
      DeleteBitmaps(ExpandConstant('{app}'));
    end;
  end;
end;

但是根据您需要清理的内容数量,最好创建一个特殊的帮助程序,该程序是安装的一部分,可以在卸载应用程序时执行(使用 [UninstallRun] 部分).

I am new to Inno Setup. Stuck on one issue ~ how to configure the uninstall piece to remove all files, folders, subfolders, and even new files/folders etc. created by application (in other words, a 100% removal of the application and associated files).

I hunted around here and also on their forum, and came up empty. Can anyone point me to a document, FAQ etc. regarding how to do this?

UPDATE

Thanks for all the feedback so far (very awesome). So it looks like I can delete everything using the {app}*.* directive in the uninstall section. Also looks like everyone is advising against it. So the question now becomes (I am wondering if this should be a totally new question) is there a way during the uninstall that we can ask the user 'Do you want to remove all project files associated with this application?' and if they answer YES, to run the uninstall {app}*.* piece?

Thanks -

解决方案

You should probably have made this a totally new question, but I'll answer your updated question here as well. Have a look at the section "Pascal Scripting: Uninstall Code" in the Inno Setup Documentation.

To give an example how to conditionally delete data files as part of the uninstallation process:

[Code]

procedure DeleteBitmaps(ADirName: string);
var
  FindRec: TFindRec;
begin
  if FindFirst(ADirName + '\*.*', FindRec) then begin
    try
      repeat
        if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin
          if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin
            DeleteBitmaps(ADirName + '\' + FindRec.Name);
            RemoveDir(ADirName + '\' + FindRec.Name);
          end;
        end else if Pos('.bmp', AnsiLowerCase(FindRec.Name)) > 0 then
          DeleteFile(ADirName + '\' + FindRec.Name);
      until not FindNext(FindRec);
    finally
      FindClose(FindRec);
    end;
  end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then begin
    if MsgBox('Do you want to delete all data files?', mbConfirmation,
        MB_YESNO) = IDYES 
    then begin
      DeleteBitmaps(ExpandConstant('{app}'));
    end;
  end;
end;

But depending on the amount of stuff you need to clean up you might be better off to create a special helper program that is part of the installation, and which can be executed during the uninstallation of the app (using an entry in the [UninstallRun] section).

这篇关于如何配置Inno Setup卸载所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆