[英]Inno setup enumerator
I'm trying to enumerate the Properties_ property of the IIsWebServer using the WbemScripting.SWbemLocator object. 我正在尝试使用WbemScripting.SWbemLocator对象枚举IIsWebServer的Properties_属性。 My goal is to use PascalScript code to retrieve the server-bindings of a website. 我的目标是使用PascalScript代码检索网站的服务器绑定。 In VBScript, I have the following code: 在VBScript中,我有以下代码:
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
I wrote this code freehand so it may not be exact, but I would like to do it in PascalScript in a similar fashion. 我是徒手编写此代码的,所以可能不太准确,但是我想以类似的方式在PascalScript中进行编写。 The part I am stuck on is enumerating through the ServerBindings. 我坚持的部分是通过ServerBindings枚举的。 I have tried many things to get it to work and at the current point I'm at, I have the following PascalScript: 我已经尝试了很多方法来使其正常工作,目前,我具有以下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; 结束;
In JavaScript, to get the ServerBindings, you must us something similar to the following: 在JavaScript中,要获取ServerBindings,您必须使用类似于以下内容的东西:
var e = new Enumerator(nodeObj.Properties_);
for (; ! e.atEnd(); e.moveNext()) {
var prop = e.item();
if (prop.Name == 'ServerBindings') {
// Do something
}
}
Any help would be appreciated. 任何帮助,将不胜感激。 Thank you. 谢谢。
Inno code unfortunately does not support doing COM enumeration natively, but you can get support by using a helper DLL. 不幸的是,Inno代码本身不支持执行COM枚举,但是您可以通过使用辅助DLL获得支持。 See here for details. 有关详细信息,请参见此处 。
If you just want to access a known named property, though -- just do it. 但是,如果您只想访问已知的命名属性,请执行此操作。
nodeObj.ServerBindings
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.