Inno Setup:如何在“运行"部分或“运行"部分之前运行代码过程? [英] Inno Setup: How to run a code procedure in Run section or before Run section?

查看:344
本文介绍了Inno Setup:如何在“运行"部分或“运行"部分之前运行代码过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在安装新数据库之前删除旧数据库,以便为用户更新它.

I want to remove the old database before installing the new one, to update it for the user.

我有以下情况:

在我的Components部分中,我为用户提供了一个选项:

In my Components section I have an option for the user:

[Components]
Name: "updateDatabase";  Description: "Update Database";  Types: custom; \
    Flags: checkablealone disablenouninstallwarning

我在Code部分中有一个过程,如果用户选择了该选项,则在运行部分中执行该过程,然后再安装新的.

And I have in Code section, a procedure to execute, if the user selects this option, in the run section, before installing the new one.

[Code]
procedure RemoveOldDatabase();
begin
...
end;

[Run]
**--> Here I want to call RemoveOldDatabase if Components: updateDatabase is checked**
Filename: "database.exe"; StatusMsg: "Installing new database..."; Components: updateDatabase

新数据库的安装正常.问题是我想在安装新的旧计算机之前删除旧的计算机,并调用过程RemoveOldDatabase.

The installation of the new database works fine. The problem is I want to remove the old one before installing the new one, calling the procedure RemoveOldDatabase.

仅使用Inno Setup可以吗?

Is it possible by only using Inno Setup?

谢谢.

推荐答案

在我看来,一种非常简单且仍具有描述性的方法是,以 [Run] 部分条目.在处理条目之前,一次执行 BeforeInstall 参数函数(并且只有在处理完之后,在您的情况下才是选择组件时).您可以这样写:

One way, in my view really simple and still descriptive, is to execute your procedure as a BeforeInstall parameter function of your [Run] section entry. A BeforeInstall parameter function is executed once right before an entry is processed (and only if it's processed, which in your case is when the component is selected). You would write just this:

[Run]
Filename: "database.exe"; Components: UpdateDatabase; BeforeInstall: RemoveOldDatabase

[Code]
procedure RemoveOldDatabase;
begin
  { ... }
end;

这篇关于Inno Setup:如何在“运行"部分或“运行"部分之前运行代码过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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