简体   繁体   English

Inno Setup检测是否已安装Apache

[英]Inno Setup detect if Apache is installed

Is there a foolproof way to detect using Inno Setup if Apache for Windows is installed on a computer? 如果在计算机上安装了Apache for Windows,是否有万无一失的方法来检测是否使用Inno Setup? I'm using the Apache lounge version ( https://www.apachelounge.com/download/ ) which doesn't have a built-in installer but it does install a specific service if needed. 我正在使用Apache休息室版本( https://www.apachelounge.com/download/ ),它没有内置的安装程序,但是在需要时会安装特定的服务。

I can search whether that Windows service is present on the machine, but I'm afraid that other Apache versions might install a different service or no service at all (but it may still be running in the background and interfering). 我可以搜索计算机上是否存在Windows服务,但是恐怕其他Apache版本可能会安装其他服务或根本没有安装任何服务(但它可能仍在后台运行并产生干扰)。

You can check for any running process whose name includes "apache" keyword (even services are processes). 您可以检查名称中包含“ apache”关键字的任何正在运行的进程(甚至服务都是进程)。

You can use the code from this answer: 您可以使用以下答案中的代码:
How to check with Inno Setup, if a process is running at a Windows 2008 R2 64bit? 如何使用Inno Setup检查进程是否在Windows 2008 R2 64bit上运行?

Just replace the query with: 只需将查询替换为:

Format('SELECT Name FROM Win32_Process Where Name like "%%%s%%"', [FileName])

And then you can use it like: 然后您可以像这样使用它:

function InitializeSetup(): Boolean;
begin
  Result := True;
  if IsAppRunning('apache') then
  begin
    MsgBox('Apache is installed and running, cannot proceed.', mbError, MB_OK);
    Result := False;
  end;
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM