使用嵌入式 UI 安装一系列嵌入式 MSI 包 - 显示通用进度条 [英] Install a chain of embedded MSI packages each using an embedded UI - display common progress bar

查看:11
本文介绍了使用嵌入式 UI 安装一系列嵌入式 MSI 包 - 显示通用进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows Installer 4.5 新功能和 WiX 来生成 MSI 包.

I'm using Windows Installer 4.5 new features and WiX to generate MSI packages.

我创建了一个 MSI 链安装,以便将其他 MSI 包的集合安装为一个事务.每个包都使用新的嵌入式 UI 选项,因此 UI 可以是 WPF.目前一切正常.

I have created an MSI chain installation in order to install a collection of other MSI packages as a transaction. Each package is using the new Embedded UI option so the UI can be WPF. Everything works OK this far.

除了目标之一是为所有安装显示一个共同的进度条.此时,我在链安装程序中有一个进度条,但在其他包开始运行之前,这个进度条已达到 100%.

Except one of the goals would be to display a common progress bar for all installs. At this moment, I have a progress bar in the chain installer, but this one reaches 100% before the other packages start to run.

我读过一篇文章,MsiEmbeddedChainer 的乐趣,这说明我想要的东西可以实现.但我无法让它工作.我想要更详细的解释,也许还有一些代码示例.

I have read a post, Fun with MsiEmbeddedChainer, that states that what I want can be achieved. But I can't get it to work. I would like a bit more detailed explanations and maybe some code samples.

推荐答案

您可以通过向安装程序发出 INSTALLMESSAGE_PROGRESS 消息来手动控制进度条的状态.详情可在此处找到:

You can manually control the status of the progress bar by issuing INSTALLMESSAGE_PROGRESS messages to the installer. Details can be found here:

http://msdn.microsoft.com/en-us/library/aa370354.aspx

特别是,您需要一个自定义操作来管理状态栏(它将负责对 MsiProcessMessage 进行适当的调用.我建议您也使用它来生成子安装程序.以下是一些伪代码来说明我的想法:

In particular, you'll need a custom action to manage the status bar (it is what will be responsible for making the appropriate calls to MsiProcessMessage. I recommend that you also use it to spawn the sub-installers. Here is some pseudocode to illustrate what I have in mind:

LONG LaunchSubinstallersCA(MSIHANDLE current_installer)
{
    // Initialize the progress bar range and position
    MsiProcessMessage(current_installer, reset_message); // see MSDN for details

    for each (subinstaller in list_of_installers)
    {
        launch subinstaller;  // see MSDN for details

        // Update the progress bar to reflect most recent changes
        MsiProcessMessage(current_installer, increment_message); // see MSDN for details
    }

    return (result);
}

主要的缺点是进度条会以一种有点断断续续的方式前进.如果你真的想变得更有趣并让它更流畅,你可以启动一个单独的侦听器"线程,等待子安装程序的更新,以对进度条进行更细粒度的增量.类似的东西:

The main down-side is that the progress bar will progress in a somewhat choppy fashion. If you really wanted to get fancy and make it smoother, you could launch a separate "listener" thread that would wait for updates from the sub-installer to make finer-grained increments to the progress bar. Something like:

LONG LaunchSubinstallersCA(MSIHANDLE current_installer)
{
    // Initialize the progress bar range and position
    MsiProcessMessage(current_installer, reset_message); // see MSDN for details

    launch_listener_thread();  // launches listener_thread_proc (see below)

    for each (subinstaller in list_of_installers)
    {
        launch subinstaller;  // see MSDN for details
    }

    tell_listener_thread_to_stop();
    optionally_wait_for_listener_thread_to_die();

    return (result);
}

void listener_thread_proc()
{
    // Loop until told to stop
    while (!time_for_me_to_stop)
    {
        // Listen for update from sub-installer
        timed_wait_for_update();  // probably required IPC, perhaps a named event?

        // Only update the progress bar if an update message was actually received
        if (!timeout)
        {
            // Update the progress bar to reflect most recent changes
            MsiProcessMessage(current_installer, increment_message); // see MSDN for details
        }
    }
}

显然,每个子安装程序都必须能够通知主安装程序已取得进展,因此这可能需要对您的产品进行更广泛的更改.是否值得努力取决于您.

Obviously each sub-installer would have to be able to signal the main installer that progress has been made, so this will potentially require more extensive changes across your product. Whether or not that is worth the effort is up to you.

这篇关于使用嵌入式 UI 安装一系列嵌入式 MSI 包 - 显示通用进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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