3

我正在寻找一种方法来确定用户是否已经安装了 IIS 版本。如果他不这样做,我将继续运行我的 IIS 安装脚本。

我知道我做的异常处理条款:

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

但由于某种原因,我的编译器版本似乎无法识别 RaiseException。我也试过包括

uses  
SysUtils;  

但编译器甚至无法识别 SysUtils。是否有类似注册表项的东西,我可以查看以确定是否已安装 IIS?
任何帮助将非常感激。

4

3 回答 3

4

Rishi 您正在使用RaiseException具有 2 个参数的函数,但此函数仅支持一个。

procedure RaiseException(const Msg: String);

尝试像这样使用此功能

var
 IIS : variant;
begin    
  try
    IIS := CreateOleObject('IISNamespace');
  except
    RaiseException('IIS not installed. Setup will now install IIS on your machine');
  end;
end;
于 2010-11-18T23:19:00.760 回答
2

尝试:

[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

;

于 2011-01-23T23:01:27.247 回答
2

IIS 始终安装到 %windir%\system32\inetsrv,因此您应该检查此目录下是否存在特定文件。例如,对于 IIS 6/7,w3wp.exe 应该存在于该文件夹中。

于 2010-11-19T14:29:04.197 回答