如何在Inno Setup中延迟而不冻结

蓝眼睛789

您好,我想知道如何在Inno Setup Pascal脚本中将工作(或命令)延迟指定的时间。

内置的功能可在Sleep(const Milliseconds: LongInt)睡眠时冻结所有工作。

而且,我实现的以下功能也使WizardForm内置Sleep()函数无法响应但不会冻结

procedure SleepEx(const MilliSeconds: LongInt);
begin
  ShellExec('Open', 'Timeout.exe', '/T ' + IntToStr(MilliSeconds div 1000), '', SW_HIDE,
            ewWaitUntilTerminated, ErrorCode);
end;

我也读过这篇文章,但不知道如何在我的函数中使用它。

我想知道如何WaitForSingleObject在此SleepEx功能中使用

在此先感谢您的帮助。

马丁·普里克里(Martin Prikryl)

使用自定义进度页(CreateOutputProgressPage功能):

procedure CurStepChanged(CurStep: TSetupStep);
var 
  ProgressPage: TOutputProgressWizardPage;
  I, Step, Wait: Integer;
begin
  if CurStep = ssPostInstall  then
  begin
    // start your asynchronous process here

    Wait := 5000;
    Step := 100; // smaller the step is, more responsive the window will be
    ProgressPage :=
      CreateOutputProgressPage(
        WizardForm.PageNameLabel.Caption, WizardForm.PageDescriptionLabel.Caption);
    ProgressPage.SetText('Doing something...', '');
    ProgressPage.SetProgress(0, Wait);
    ProgressPage.Show;
    try
      // instead of a fixed-length loop,
      // query your asynchronous process completion/state
      for I := 0 to Wait div Step do
      begin
        // pumps a window message queue as a side effect, what prevents the freezing
        ProgressPage.SetProgress(I * Step, Wait);
        Sleep(Step);
      end;
    finally
      ProgressPage.Hide;
      ProgressPage.Free;
    end;
  end;
end;

这里的关键点是,该SetProgress调用会抽出一个窗口消息队列,这可以防止冻结。

在此处输入图片说明


尽管实际上,您不希望使用定长循环,而是使用不确定的进度条并在循环中查询DLL的状态。

为此,请参见Inno Setup:字幕样式进度条,以获取C#DLL中冗长的同步操作

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在不冻结线程的情况下延迟答案?

如何在不阻止Inno Setup UI的情况下执行7zip?

如何在Inno Setup中最小化安装程序?

如何在Inno Setup中解析JSON字符串?

Inno Setup:如何在“运行”部分操作进度栏?

Inno Setup:如何在“注册”部分操作进度栏?

如何在Inno Setup中使用空格处理路径?

如何在Inno Setup中获取MSI文件的文件版本

Inno Setup-如何在线验证序列号

如何在Inno Setup中读取XML的标签属性

如何在Inno Setup iss文件中添加DLL函数?

如何在Maven版本中使用Inno Setup?

如何在Inno Setup中使用UTC

如何在Inno Setup中修改错误消息?

如何在Inno Setup中的安装后强制重启

如何在Inno Setup中将LanguageID写入注册表?

如何在Inno Setup的[CustomMessages]部分中使用通配符?

如何在Inno Setup中使用PrepareToTinstall函数的NeedsRestart参数?

如何在inno setup中进行mysql的静默安装?

如何在Inno设置中为SendMessage函数实现MAKELPARAM?

如何在Inno Setup中翻译MsgBox中包含的文本?

如何在不导致UI冻结的情况下延迟执行特定任务

如何在Inno设置中检查64/32位

如何在 Inno Setup iss 文件中调用 GetNativeSystemInfo?

Inno setup - 如何在设置悬停中更改版本?

如何在 Inno Setup Pascal Script 中取消引用指针?

如何在不冻结应用程序的情况下延迟代码

inno setup - 如何在屏幕中央显示启动画面?

如何在 Inno Setup 出现错误时继续下载?