InnoSetup 卸载询问消息 - Pascal 编码

发布于 2024-09-03 01:09:57 字数 207 浏览 2 评论 0原文

我已经为我的一些游戏创建了一个安装程序,我希望卸载程序询问我是否要保存我的游戏文件。 像这样的事情:当我执行 uninstall.exe 时询问我“您想保留所有已保存的游戏吗?”是还是不是。如果我点击“是”,我的保存文件将保留,并且我的程序文件将被卸载;如果我点击“否”,我的程序文件(包括保存文件)将被卸载。 InnoSetup 执行此操作的 PASCAL 代码是什么?

非常感谢!

I have created an installer for some of my games and I want the uninstaller to ask me if I want to save my game files.
Something like this: when I execute the uninstall.exe to ask me 'Do you want to keep all saved games?' YES or NO. If I hit YES my save files remain and my program files are uninstalled and if I hit NO my program files inclusive save files to be uninstalled.
What is the PASCAL code for InnoSetup to do this?

Thank you very much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

星光不落少年眉 2024-09-10 01:09:57

您可以执行以下操作:


; -- 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。

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

You can do something like:


; -- 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;

You would want to use the latest version of InnoSetup as that's what I tested with. The sample above is based on the UninstallCodeExample.iss included with the InnoSetup compiler.

I added a line of code to show how to delete a file. It calls the DeleteFile function. You would need to add a DeleteFile for each file you want to remove at uninstall that isn't in your [Files] section.

倦话 2024-09-10 01:09:57

可能与您的问题有关,如果您只想将卸载消息更改为“您确定要完全删除 %1 及其所有组件吗?”对于其他内容,您可以通过修改其消息来完成此操作,例如

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

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

Possibly related to your question, if you just want to change the uninstall message from "Are you sure you want to completely remove %1 and all of its components?" to something else, you can do this by modifying its message, like

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文