具有Inno设置的AppMutex:等待几秒钟,然后提示 [英] AppMutex with Inno Setup: Wait few seconds before prompt
问题描述
将Inno设置与AppMutex
一起使用可以很好地工作-启动设置并且互斥锁仍然退出时,系统会提示用户关闭此应用程序.
Using Inno Setup together with an AppMutex
works fine - when the setup is started and the mutex still exits, the user is prompted to close this application.
但是下面的问题: 如果程序自身关闭,是否有办法告诉Inno Setup等待2-3秒,然后才向用户显示此提示?
But following question: Is there a way to tell Inno Setup to wait 2-3 seconds if the program closes itself before showing the user this prompt?
原因是我正在从程序本身运行Inno设置以进行自动更新.在执行安装文件后,程序会立即自行关闭,但是很显然,这会花费太长时间(至少在某些系统上).因此,即使程序已经关闭,Inno Setup也会向用户显示此对话框(在本例中为无用对话框).
The reason is that I'm running the Inno Setup from the program itself for auto-update purpose. Directly after the setup file is executed the program closes itself, but obviously that takes too long (at least on some systems). So Inno Setup shows this - in this case - useless dialog to the user although the program is closing itself already.
因此,我希望Inno Setup等待2-3秒,并且只有在此之后互斥锁仍然存在的情况下,它才应该向用户显示提示.
Therefore I would like to accomplish that Inno Setup waits 2-3 seconds and only if the mutex still exists after that time it should show the prompt to the user.
有没有办法做到这一点?
Is there a way to accomplish this?
推荐答案
With such requirement, you cannot use the built-in AppMutex
directive.
您必须使用 CheckForMutexes
函数实现互斥体检查:
You have to implement the mutex check yourself using CheckForMutexes
function:
[Code]
const
MutexName = 'MutexName';
function InitializeSetup: Boolean;
var
WaitInterval: Integer;
Wait: Integer;
begin
Wait := 3000;
WaitInterval := 250;
while (Wait > 0) and CheckForMutexes(MutexName) do
begin
Log('Application is still running, waiting');
Sleep(WaitInterval);
Wait := Wait - WaitInterval;
end;
while CheckForMutexes(MutexName) do
begin
if MsgBox(
FmtMessage(SetupMessage(msgSetupAppRunningError), ['MyApplication']),
mbError, MB_OKCANCEL) <> IDOK then
begin
Abort;
end;
end;
Result := True;
end;
这篇关于具有Inno设置的AppMutex:等待几秒钟,然后提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!