1
我想枚举使用WbemScripting.SWbemLocator对象的IIsWebServer的Properties_属性。我的目标是使用PascalScript代码来检索网站的服务器绑定。在VBScript中,我有以下代码:Inno setup枚举器
Dim site, binding, url
Set site = GetObject("IIS://localhost/W3SVC/1")
For Each binding In site.ServerBindings
url = binding
Exit For
Next
If Left(url, 1) = ":" Then
url = "localhost" & url
End If
If Right(url, 1) Then
url = Left(url, Len(url) - 1)
End If
Set site = Nothing
我写了这个代码写意所以它可能不准确,但我想这样做在PascalScript以类似的方式。我坚持的部分是通过ServerBindings枚举。我已经尝试了很多事情来实现它的功能,并且在当前时刻,我拥有以下PascalScript:
function GetWebSites() : Array of String;
var
locatorObj, providerObj, nodeObj, appRoot: Variant;
props : String;
begin
locatorObj := CreateOleObject('WbemScripting.SWbemLocator');
providerObj := locatorObj.ConnectServer(GetComputerNameString(), 'root/MicrosoftIISv2');
nodeObj := providerObj.Get('IIsWebServer=''W3SVC/1''');
props := nodeObj.Properties_;
// How do I enumerate through the properties here? Or, my actual goal is from this point how do I get the ServerBindings (or the first element in the ServerBindings array)?
end;
在JavaScript中,得到ServerBindings,你必须我们类似如下的内容:
var e = new Enumerator(nodeObj.Properties_);
for (; ! e.atEnd(); e.moveNext()) {
var prop = e.item();
if (prop.Name == 'ServerBindings') {
// Do something
}
}
任何帮助,将不胜感激。谢谢。