是否可以在尝试安装程序之前检查程序是否已在运行? (创新设置) [英] Is it possible to check if program is already running before trying to install it? (Inno Setup)

查看:119
本文介绍了是否可以在尝试安装程序之前检查程序是否已在运行? (创新设置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Inno Setup创建安装程序.启动创建的安装程序时,我需要检查要安装的程序是否已在运行,如果正在运行,则必须显示相应的消息,直到关闭或退出. 可以这样做吗?

I'm using Inno Setup to create the installer. When I launch the installer I've created I need to check whether the program I'm trying to install is already running or not and if it is running then I have to show the corresponding message until I close it or exit. Is it possible to do that?

推荐答案

如果它是您的应用程序,请使其创建互斥体.然后,您可以使用 AppMutex指令.

If it is your application, make it create a mutex. Then you can use AppMutex directive.

[Setup]
AppMutex=MyProgMutex

如果无法修改应用程序,则需要在Inno Setup中编写对运行应用程序的检查的代码.例如,您可以在@RRUZ的答案中使用IsAppRunning函数到如何使用Inno Setup进行检查(如果进程正在运行). Windows 2008 R2 64位? InitializeSetup事件函数.

If you cannot modify the application, you need to code the check for running application in Inno Setup. You can for example use IsAppRunning function from the answer by @RRUZ to How to check with Inno Setup, if a process is running at a Windows 2008 R2 64bit? in InitializeSetup event function.

function InitializeSetup(): Boolean;
begin
  Result := True;
  while IsAppRunning('MyProg.exe') do
  begin
    if MsgBox('Program is running, please close it', mbError, MB_OKCANCEL) = IDCANCEL then
    begin
      Result := False
      Exit;
    end;
  end;
end;


基于有关卸载程序的类似问题:
像准备安装页面-Inno Setup一样,准备卸载


Based on a similar question on uninstaller:
Preparing to Uninstall like Preparing to Install Page - Inno Setup

这篇关于是否可以在尝试安装程序之前检查程序是否已在运行? (创新设置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆