您好,我想知道如何在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
功能中使用。
在此先感谢您的帮助。
使用自定义进度页(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的状态。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句