简体   繁体   English

如何使用INNO设置检测IIS的现有安装?

[英]How to detect an existing installation of IIS using INNO setup?

I am looking for a way to determine if the user already has a version of IIS installed. 我正在寻找一种方法来确定用户是否已安装了IIS版本。 If he doesn't, I will go ahead and run my IIS installation script. 如果他没有,我将继续运行我的IIS安装脚本。

I know of the exception handling clause where I do : 我知道我所做的异常处理条款:

  try
    IIS := CreateOleObject('IISNamespace');  
  except  
    RaiseException(ExceptionType, ‘IIS not installed. Setup will now install IIS on your machine. ’#13#13'(Error ‘’’+ExceptionParam+’’’ occured)’);  
  end;

but for some reason, my compiler version doesn't seem to recognise RaiseException. 但出于某种原因,我的编译器版本似乎没有识别出RaiseException。 I also tried including 我也试过包括

uses  
SysUtils;  

but the compiler won't recognize SysUtils even. 但编译器甚至不会识别SysUtils。 Is there something like a registry key that I can look at to determine whether IIS is already installed or not? 是否有类似注册表项的内容我可以查看以确定是否已安装IIS?
Any help would be much appreciated. 任何帮助将非常感激。

Rishi you are using the RaiseException function with 2 parameters, but the this function only support one. Rishi你正在使用带有2个参数的RaiseException函数,但是这个函数只支持一个。

procedure RaiseException(const Msg: String);

try using this function like this 尝试使用这样的功能

var
 IIS : variant;
begin    
  try
    IIS := CreateOleObject('IISNamespace');
  except
    RaiseException('IIS not installed. Setup will now install IIS on your machine');
  end;
end;

IIS always installs to %windir%\\system32\\inetsrv so you should check if specific files exist under this directory. IIS始终安装到%windir%\\ system32 \\ inetsrv,因此您应检查此目录下是否存在特定文件。 For example, w3wp.exe should exist in this folder for IIS 6/7. 例如,IIS 6/7的此文件夹中应存在w3wp.exe。

Try: 尝试:

[CustomMessages]
iis_title=Internet Information Services (IIS)


[Code]
function iis(): boolean;
begin
    if not RegKeyExists(HKLM, 'SYSTEM\CurrentControlSet\Services\W3SVC\Security') then
        MsgBox(FmtMessage(CustomMessage('depinstall_missing'), [CustomMessage('iis_title')]), mbError, MB_OK)
    else
        Result := true;
end

; ;

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

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