【问题标题】:InnoSetup Uninstall Ask Message - Pascal CodingInnoSetup 卸载询问消息 - 帕斯卡编码
【发布时间】:2017-01-23 07:27:59
【问题描述】:

我为我的一些游戏创建了安装程序,我希望卸载程序询问我是否要保存我的游戏文件。 像这样:当我执行卸载程序问我“你想保留所有保存的游戏吗?”是还是不是。如果我点击“是”,我的保存文件仍然存在并且我的程序文件被卸载,如果我点击“否”,我的程序文件包括要卸载的保存文件。 InnoSetup 的 PASCAL 代码是什么?

非常感谢!

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    你可以这样做:

    
    ; -- UninstallCodeExample1.iss --
    ;
    ; This script shows various things you can achieve using a [Code] section for Uninstall
    [Setup]
    AppName=My Program
    AppVerName=My Program version 1.5
    DefaultDirName={pf}\My Program
    DefaultGroupName=My Program
    UninstallDisplayIcon={app}\MyProg.exe
    OutputDir=userdocs:Inno Setup Examples Output
    
    [Files]
    Source: "MyProg.exe"; DestDir: "{app}"
    Source: "MyProg.chm"; DestDir: "{app}"
    Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
    
    [Code]
    function InitializeUninstall(): Boolean;
    begin
      Result := MsgBox('InitializeUninstall:' #13#13 'Uninstall is initializing. Do you really want to start Uninstall?', mbConfirmation, MB_YESNO) = idYes;
      if Result = False then
        MsgBox('InitializeUninstall:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
    end;
    
    procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
    var
    mRes : integer;
    begin
      case CurUninstallStep of
        usUninstall:
          begin
            mRes := MsgBox('Do you want to remove all files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
            if mRes = IDYES then
              begin
                 MsgBox ('Really remove the files', mbInformation, MB_OK)
                 DeleteFile('path\filename.ext');
              End
            else
              MsgBox ('Don''t remove the game files', mbInformation, MB_OK);        
            // ...insert code to perform pre-uninstall tasks here...
          end;
      end;
    end;

    您可能希望使用最新版本的 InnoSetup,因为这是我测试过的。上面的示例基于 InnoSetup 编译器中包含的 UninstallCodeExample.iss。

    我添加了一行代码来展示如何删除文件。它调用 DeleteFile 函数。您需要为要在卸载时删除但不在 [Files] 部分中的每个文件添加 DeleteFile。

    【讨论】:

      【解决方案2】:

      可能与您的问题有关,如果您只想将卸载消息从“您确定要完全删除 %1 及其所有组件吗?”对于别的东西,你可以通过修改它的消息来做到这一点,比如

      [Messages]
      ConfirmUninstall=Are you really really sure you want to remove %1?
      

      参考:http://www.jrsoftware.org/ishelp/index.php?topic=messagessection

      【讨论】:

      • 谢谢!我正要创建一个自定义页面。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多