加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

wix – 使用嵌入式UI安装一系列嵌入式MSI包 – 显示常用进度条

发布时间:2020-12-14 02:28:06 所属栏目:Windows 来源:网络整理
导读:我正在使用 Windows Installer 4.5新功能和WiX生成 MSI个软件包. 我已经创建了一个MSI链安装,以便将其他MSI包的集合安装为事务.每个软件包都使用新的嵌入式UI选项,因此UI可以是WPF.到目前为止一切正常. 除了其中一个目标是显示所有安装的公共进度条.此时,我
我正在使用 Windows Installer 4.5新功能和WiX生成 MSI个软件包.

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

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

我已经阅读了一篇文章,Fun with MsiEmbeddedChainer,其中说明我想要的东西可以实现.但我无法让它发挥作用.我想要更详细的解释和一些代码示例.

解决方法

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

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

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

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

主要的缺点是进度条会以一种有点波涛汹涌的方式进展.如果你真的想要变得更加流畅并且使它更流畅,你可以启动一个单独的“监听器”线程,该线程将等待来自子安装程序的更新,以便对进度条进行更细粒度的增量.就像是:

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读