本文介绍了WiX:在 CustomAction 期间动态更改状态文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 wix 安装程序中有一个相当长的 CustomAction,我希望能够在操作运行时更改状态:..."文本,以查看其内部状态的进度和更新.我知道如何设置自定义操作的进度文本 - 但我想要的是在自定义操作运行期间动态更改进度文本.

I have a pretty lengthy CustomAction in a wix installer, and I want to be able to change the 'Status: ...' text while the operation runs, to see that there is progress and update on its internal status.I know how to set the progresstext of a custom action - but what I want is to dynamically change the progress text during the run of the custom action.

推荐答案

Deferred Custom Actions 可以调用 MsiProcessMessage 函数.然后,您可以使用 INSTALLMESSAGE_ACTIONSTART、INSTALLMESSAGE_ACTIONDATA 和 INSTALLMESSAGE_PROGRESS 将消息发布到 UI.

Deferred Custom Actions can call the MsiProcessMessage function. You can then use INSTALLMESSAGE_ACTIONSTART, INSTALLMESSAGE_ACTIONDATA and INSTALLMESSAGE_PROGRESS to publish messages up to the UI.

另一种可能性是将您的自定义操作分解为更小的自定义操作,并使用 ProgressText(ActionText 表)来描述安装的不同阶段.(让每个 CA 有一个单一的责任.)

Another possibility would be to break your custom action up into smaller custom actions and use the ProgressText (ActionText table) to describe different phases of installation. ( Make each CA have a single responsibility. )

有时当 CA 做了太多工作时,很难正确计划回滚.

Sometimes when a CA does too much work it's hard to plan rollbacks correctly.

获取上下文信息延迟执行自定义操作

MsiProcessMessage 函数

使用 C#/DTF 看起来像:

Using C#/DTF it looks something like:

    using (Record record = new Record(0))
    {
        record.SetString(0, "foo");
        session.Message(InstallMessage.ActionData, record);
    }

using 语句处理记录以释放底层 MSI 句柄.记录中的字段数量以及您如何设置数据将取决于 ActionText 表中定义的模板.

The using statement disposes the record to free up the underlying MSI handles. The number of fields in the record and how you set the data is going to depend on the template defined in the ActionText table.

这篇关于WiX:在 CustomAction 期间动态更改状态文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!