gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:07:45 24 4
gpt4 key购买 nike

我正在使用 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
}
}
}

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

关于wix - 使用嵌入式 UI 安装一系列嵌入式 MSI 包 - 显示通用进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/153431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com